Java Reference
In-Depth Information
public void
flush()
throws
IOException
Flushes the output stream. This forces an actual physical write to the fi le of any data that
has been buffered and not yet physically written to the fi le. Normally, you should not need to
invoke
flush
.
public void
writeBoolean(
boolean
b)
throws
IOException
Writes the
boolean
value
b
to the output stream.
public void
writeChar(
int
n)
throws
IOException
Writes the
char
value
n
to the output stream. Note that it expects its argument to be an
int
value. However, if you simply use the
char
value, then Java will automatically type cast it to an
int
value. The following are equivalent:
outputStream.writeChar((
int
)'A');
and
outputStream.writeChar('A');
public void
writeDouble(
double
x)
throws
IOException
Writes the
double
value
x
to the output stream.
public void
writeFloat(
float
x)
throws
IOException
Writes the
float
value
x
to the output stream.
public void
writeInt(
int
n)
throws
IOException
Writes the
int
value
n
to the output stream.
public void
writeLong(
long
n)
throws
IOException
Writes the
long
value
n
to the output stream.
public void
writeObject(Object anObject)
throws
IOException
Writes its argument to the output stream. The object argument should be an object of a
serializable class, a concept discussed in Chapter 10.
Throws:
Various
IOException
s.
public void
writeShort(
short
n)
throws
IOException
Writes the
short
value
n
to the output stream.
public void
writeUTF(String aString)
throws
IOException
Writes the
String
value
aString
to the output stream.
UTF
refers to a particular method of
encoding the string. To read the string back from the fi le, you should use the method
readUTF
of
the class
ObjectInputStream
.