Example #1
0
 private void readFromBuffer(ByteBuffer buf) throws IOException {
   this.buf = buf;
   buf.order(ByteOrder.LITTLE_ENDIAN);
   header = new Header();
   header.read(buf);
   fixupHeader();
 }
Example #2
0
 public void write(FileOutputStream fos) throws IOException {
   FileChannel chan = fos.getChannel();
   // Create ByteBuffer for header in case the start of our
   // ByteBuffer isn't actually memory-mapped
   ByteBuffer hdr = ByteBuffer.allocate(Header.writtenSize());
   hdr.order(ByteOrder.LITTLE_ENDIAN);
   header.write(hdr);
   hdr.rewind();
   chan.write(hdr);
   buf.position(Header.writtenSize());
   chan.write(buf);
   chan.force(true);
   chan.close();
 }