1. FileInputStream reading data One byte array at a time byte[]
Use FileInputStream to read one byte array at a time:
int read (byte[] b)
return value : The return value is actually the number of bytes actually read.
2. code example:
1 PackageCom.himi.fileinputstream;2 3 ImportJava.io.FileInputStream;4 Importjava.io.IOException;5 6 7 8 /**9 * Ten * Use FileInputStream one byte array at a time: int read (byte[] b) One * Return value: The return value is actually the number of bytes actually read A * - */ - the - Public classFileInputStreamDemo1 { - - Public Static voidMain (string[] args)throwsIOException { +FileInputStream FIS =NewFileInputStream ("A.txt"); - //Development Time final version code + byte[] Bys =New byte[1024]; A intLen = 0; at while(len = Fis.read (bys))! =-1) { -System.out.print (NewString (bys,0, Len)); - } - - } - in}
Run the effect as follows:
Java Fundamentals Hardening IO Stream Note 27:fileinputstream reading data one byte array at a time byte[]