Hi.
I'm considering changing my file access code to accomodate FileChannels and ByteBuffers, but am having a bit of trouble figuring out how to convert the readUTF method to its NIO equivalent. It doesn't seem very efficient.
ByteBuffer bb = ......
(read info into bb)
//Here reading the first unsigned short value of the UTF that tells
//me how many encoded bytes to get and using this number to create a
//byte array of exactly that size
byte[] buffer = new byte[bb.getShort()];
//Read info from file into the buffer, the size of buffer
bb.get(buffer);
//then right after this instead of db.readUTF() do
new
String(buffer, "UTF-8")
Will this work? If it does, is there a better way of doing this?