Manipulating the stream of the base data type
DataInputStream
DataOutputStream
Import Java.io.datainputstream;import Java.io.dataoutputstream;import Java.io.fileinputstream;import Java.io.fileoutputstream;import Java.io.ioexception;public class Integerdemo {public static void main (string[] args) Throws IOException {mywrite (); myreader ();} private static void Mywrite () throws IOException {//TODO auto-generated method stub//Create data output stream object FileOutputStream fos = new FileOutputStream ("E:\\zikao\\file\\cs.txt");D ataoutputstream dos = new DataOutputStream (FOS);//Write Data Dos.writebyte (10 );d os.writeshort;d os.writeint (;d os.writelong (10000);d os.writefloat (12.34F);d os.writedouble (12.56); Dos.writechar (' a ');d Os.writeboolean (TRUE);//Release Resource Dos.close ();} private static void Myreader () throws IOException {//TODO auto-generated method stub//Create data input stream object FileInputStream FIS = new FileInputStream ("E:\\zikao\\file\\cs.txt");D atainputstream dis = new DataInputStream (FIS);//Read data byte B = Dis.readbyte ( ); Short s = Dis.readshort (); int i = Dis.readint (); Long L = Dis.readlong (); float F = dis.reaDfloat ();d ouble d = dis.readdouble (); char C = Dis.readchar (); Boolean bl = Dis.readboolean ();//Release Resources dis.close (); System.out.println (b); System.out.println (s); System.out.println (i); System.out.println (l); System.out.println (f); System.out.println (d); System.out.println (c); System.out.println (BL);}}
DataInputStream and DataOutputStream