Java Reference
In-Depth Information
public int readShort() throws IOException
Reads a short value from the input stream and returns that short value. If readInt tries to
read a value from the fi le and that value was not written using the method writeShort of the
class ObjectOutputStream (or written in some equivalent way), then problems will occur.
If an attempt is made to read beyond the end of the fi le, an EOFException is thrown.
public String readUTF() throws IOException
Reads a String value from the input stream and returns that String value. If readUTF tries
to read a value from the fi le and that value was not written using the method writeUTF of
the class ObjectOutputStream (or written in some equivalent way), then problems will occur.
If an attempt is made to read beyond the end of the fi le, an EOFException is thrown.
public int skipBytes( int n) throws IOException
Skips n bytes.
ObjectOutputStream
Package: java.io
The FileOutputStream class is also in this package.
Ancestor classes:
Object
|
+--OutputStream
|
+--ObjectOutputStream
public ObjectOutputStream(OutputStream streamObject)
There is no constructor that takes a fi le name as an argument. If you want to create a stream
using a fi le name, use
new ObjectOutputStream( new FileOutputStream( File_Name ))
This creates a blank fi le. If there already is a fi le named File_Name , then the old contents of the
fi le are lost.
If you want to create a stream using an object of the class File , use
new ObjectOutputStream( new FileOutputStream( File_Object ))
The constructor for FileOutputStream may throw a FileNotFoundException , which is a
kind of IOException . If the FileOutputStream constructor succeeds, then the constructor
for ObjectOutputStream may throw a different IOException.
public void close() throws IOException
Closes the stream's connection to a fi le. This method calls flush before closing the fi le.
 
Search WWH ::




Custom Search