E
Erin K
How does one read/write a file with a serialized object, then some
other data in it, so that after one reads the object, the next byte
read is whatever came after the object in the file? I want to do
something like
Writing:
FileOutputStream fos = new FileOutputStream(myfile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(some object);
for(a bunch of bytes) {
fos.write(next byte);
}
Reading:
FileInputStream fis = new FileInputStream(myfile);
ObjectInputStream ois = new ObjectInputStream(fis);
ois.readObject();
while(fis isn't empty) {
fis.readByte();
}
but I am pretty sure that the first call to readByte will go from the
beginning of the file, not after the object like I want it to.
other data in it, so that after one reads the object, the next byte
read is whatever came after the object in the file? I want to do
something like
Writing:
FileOutputStream fos = new FileOutputStream(myfile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(some object);
for(a bunch of bytes) {
fos.write(next byte);
}
Reading:
FileInputStream fis = new FileInputStream(myfile);
ObjectInputStream ois = new ObjectInputStream(fis);
ois.readObject();
while(fis isn't empty) {
fis.readByte();
}
but I am pretty sure that the first call to readByte will go from the
beginning of the file, not after the object like I want it to.