DataOutputStream.writeChar(int v) has the following syntax.
public final void writeChar(int v) throws IOException
In the following code shows how to use DataOutputStream.writeChar(int v) method.
/* w ww . j a v a 2 s.c o m*/ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void main(String[] args) throws IOException { byte[] buf = { 65, 66, 67, 68, 69, 70 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (byte b : buf) { dos.writeChar(b); } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { char c = dis.readChar(); System.out.print(c); } } }