Java tutorial
import java.io.DataOutputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { byte[] buf = { 12, 11, 22, 33, 44 }; FileOutputStream fos = new FileOutputStream("c:/test.txt"); DataOutputStream dos = new DataOutputStream(fos); int size = 0; for (byte b : buf) { dos.write(b); size = dos.size(); System.out.print("Size: " + size + "; "); } } }