DataOutputStream.size() has the following syntax.
public final int size()
In the following code shows how to use DataOutputStream.size() method.
// ww w . j a v a 2 s .c o m 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 + "; "); } } }