Here you can find the source of writeDataLengthsToHeader(FileOutputStream fpo)
public static boolean writeDataLengthsToHeader(FileOutputStream fpo)
//package com.java2s; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; public class Main { public static boolean writeDataLengthsToHeader(FileOutputStream fpo) { long len; ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); FileChannel fc = fpo.getChannel(); try {//from w w w .j a v a 2 s . c om len = fc.size(); fc.position(4); bb.putInt((int) (len - 8)); bb.flip(); fc.write(bb); fc.position(40); bb.clear(); bb.putInt((int) (len - 44)); bb.flip(); fc.write(bb); } catch (IOException e) { System.err.println("error writing data lengths."); e.printStackTrace(System.err); return false; } return true; } }