![]() |
The Java Developers Almanac 1.4 |
|
e39. Using a Random Access File try {
File f = new File("filename");
RandomAccessFile raf = new RandomAccessFile(f, "rw");
// Read a character
char ch = raf.readChar();
// Seek to end of file
raf.seek(f.length());
// Append to the end
raf.writeChars("aString");
raf.close();
} catch (IOException e) {
}
e35. Reading Text from a File e36. Reading a File into a Byte Array e37. Writing to a File e38. Appending to a File
© 2002 Addison-Wesley. |