Annihilannic
MIS
Please excuse the basic nature of this question, I'm not a fluent Java
programmer.
I'm trying to write a simple Javolution Struct to a RandomAccessFile but
keep on getting unusual exceptions or short writes (only 46 bytes being
written instead of the 212 bytes in the Struct, for example).
selectedSetup is of class Setup, which is an extension of the Struct class.
Previously I was reading these structures using stream I/O which worked
perfectly, but realised I needed switch to java.nio.channels to modify
RandomAccessFiles. I must be missing something obvious here?
Annihilannic.
programmer.
I'm trying to write a simple Javolution Struct to a RandomAccessFile but
keep on getting unusual exceptions or short writes (only 46 bytes being
written instead of the 212 bytes in the Struct, for example).
selectedSetup is of class Setup, which is an extension of the Struct class.
Code:
RandomAccessFile f = new RandomAccessFile(selectedTrack.csuFile,"rw");
selectedSetup.getByteBuffer().position(0);
// this results in a partial write
int written=f.getChannel().write(selectedSetup.getByteBuffer());
// this results in a java.lang.UnsupportedOperationException
f.write(selectedSetup.getByteBuffer().array(),212,0);
f.close();
Previously I was reading these structures using stream I/O which worked
perfectly, but realised I needed switch to java.nio.channels to modify
RandomAccessFiles. I must be missing something obvious here?
Annihilannic.