# ObjectOutputStream.PutField

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#pubctors)\|[Methods](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#inhmethods)  

# ObjectOutputStream.PutField

`
public
static

abstract
class
ObjectOutputStream.PutField
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.io.ObjectOutputStream.PutField |

<br />

*** ** * ** ***

Provide programmatic access to the persistent fields to be written to ObjectOutput.

## Summary

|                                            ### Public constructors                                            ||
|------------------------------------------------------------------------------------------------------------|---|
| ` `[PutField](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#PutField())`() ` |

|                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                  ||
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` name, double val) ` Put the value of the named double field into the persistent field.                                                                                                                                                                                                                                                                                                                 |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20float))`(`[String](https://developer.android.com/reference/java/lang/String)` name, float val) ` Put the value of the named float field into the persistent field.                                                                                                                                                                                                                                                                                                                    |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int val) ` Put the value of the named int field into the persistent field.                                                                                                                                                                                                                                                                                                                          |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` name, long val) ` Put the value of the named long field into the persistent field.                                                                                                                                                                                                                                                                                                                       |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20byte))`(`[String](https://developer.android.com/reference/java/lang/String)` name, byte val) ` Put the value of the named byte field into the persistent field.                                                                                                                                                                                                                                                                                                                       |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20java.lang.Object))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[Object](https://developer.android.com/reference/java/lang/Object)` val) ` Put the value of the named Object field into the persistent field.                                                                                                                                                                                                                                         |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20short))`(`[String](https://developer.android.com/reference/java/lang/String)` name, short val) ` Put the value of the named short field into the persistent field.                                                                                                                                                                                                                                                                                                                    |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20char))`(`[String](https://developer.android.com/reference/java/lang/String)` name, char val) ` Put the value of the named char field into the persistent field.                                                                                                                                                                                                                                                                                                                       |
| ` abstract void` | ` `[put](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#put(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` name, boolean val) ` Put the value of the named boolean field into the persistent field.                                                                                                                                                                                                                                                                                                              |
| ` abstract void` | ` `[write](https://developer.android.com/reference/java/io/ObjectOutputStream.PutField#write(java.io.ObjectOutput))`(`[ObjectOutput](https://developer.android.com/reference/java/io/ObjectOutput)` out) ` *This method was deprecated in API level 15. This method does not write the values contained by this`PutField`object in a proper format, and may result in corruption of the serialization stream. The correct way to write`PutField`data is by calling the[ObjectOutputStream.writeFields()](https://developer.android.com/reference/java/io/ObjectOutputStream#writeFields())method.* |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### PutField

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PutField ()
```

<br />

<br />

## Public methods

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                double val)
```

Put the value of the named double field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `double`: the value to assign to the field <br />   |

|                                                                                                                             Throws                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`double` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                float val)
```

Put the value of the named float field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `float`: the value to assign to the field <br />    |

|                                                                                                                            Throws                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`float` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                int val)
```

Put the value of the named int field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `int`: the value to assign to the field <br />      |

|                                                                                                                           Throws                                                                                                                            ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`int` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                long val)
```

Put the value of the named long field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `long`: the value to assign to the field <br />     |

|                                                                                                                            Throws                                                                                                                            ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`long` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                byte val)
```

Put the value of the named byte field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `byte`: the value to assign to the field <br />     |

|                                                                                                                            Throws                                                                                                                            ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`byte` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                Object val)
```

Put the value of the named Object field into the persistent field.

<br />

|                                   Parameters                                   ||
|--------|------------------------------------------------------------------------|
| `name` | `String`: the name of the serializable field <br />                    |
| `val`  | `Object`: the value to assign to the field (which may be`null`) <br /> |

|                                                                                                                                 Throws                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not a reference type |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                short val)
```

Put the value of the named short field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `short`: the value to assign to the field <br />    |

|                                                                                                                            Throws                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`short` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                char val)
```

Put the value of the named char field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `char`: the value to assign to the field <br />     |

|                                                                                                                            Throws                                                                                                                            ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`char` |

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void put (String name, 
                boolean val)
```

Put the value of the named boolean field into the persistent field.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `name` | `String`: the name of the serializable field <br /> |
| `val`  | `boolean`: the value to assign to the field <br />  |

|                                                                                                                             Throws                                                                                                                              ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`name`does not match the name of a serializable field for the class whose fields are being written, or if the type of the named field is not`boolean` |

### write

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void write (ObjectOutput out)
```

<br />

**This method was deprecated in API level 15.**   
This method does not write the values contained by this`PutField`object in a proper format, and may result in corruption of the serialization stream. The correct way to write`PutField`data is by calling the[ObjectOutputStream.writeFields()](https://developer.android.com/reference/java/io/ObjectOutputStream#writeFields())method.

Write the data and fields to the specified ObjectOutput stream, which must be the same stream that produced this`PutField`object.

<br />

|                                Parameters                                ||
|-------|-------------------------------------------------------------------|
| `out` | `ObjectOutput`: the stream to write the data and fields to <br /> |

|                                                                                          Throws                                                                                           ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                             | if I/O errors occur while writing to the underlying stream                        |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the specified stream is not the same stream that produced this`PutField`object |