RandomAccessFile.readByte() find EOF
im trying to create a log file, for which i need to use the RandomAccessFile class for, its the only class i know of which can write a string to a file with 8 bits per char. problem is, the file pointer wants to stay at the beginning of the file. i need to move it manually with seek so that i can log more than one thing. i need to feed seek the length of the file, so i figured id read with RandomAccessFile.readByte() until i reach EOF. however, when readByte reaches EOF, an exception is thrown, which stops my program.
Re: RandomAccessFile.readByte() find EOF
If you wish to just append to a file, use a FileWriter (most likely wrapped in a BufferedWriter), setting it to append to the parameter file. The file writing classes in Java need to be created in a unique way to deviate from 8bits/char ascii.
Re: RandomAccessFile.readByte() find EOF
Use This tutorial for encoding/decoding into different formats. You can then write out the values to the file using the FileWriter class as copeg said.
Re: RandomAccessFile.readByte() find EOF
excellent! works great! ty!