Parse available \ skip \ close \ read (int [] a) Method using the read and print out all the method loops content.
package com.bjpowernode.java_learning; import java.io.*; public class D96_1_CircleRead { public static void main(String[] args) throws Exception{ FileInputStream fis = new FileInputStream("C:\\Users\\lenovo1\\Workspaces\\MyEclipse CI\\Java_learning\\src\\com\\bjpowernode\\java_learning\\D95_1_FileInputStreamAnalysis.java"); byte[] bytes = new byte[1024]; //1.available方法 System.out.println(fis.available()); System.out.println("==========="); // 2.skip method fis.skip ( 2); // skip reading two bytes System.out.println ( "===========" ); // 3. print cycle the contents of the while ( to true ) { int TEMP = fis.read (bytes); IF (TEMP == -. 1) BREAK ; // convert byte array into a string of valid data of System.out.print ( new new string (bytes , 0 , TEMP)); // note is taken here of the string, here we need to know read return value of this method, we create the equivalent of a so array, each for storing // read 1KB, and 1kb, 1kb output. The reason for using a 0 to temp, front read when they are to say, the array can be filled, but when read // when the last time, there will occupy part of an array, if we use fixed-length 1024 it will put the last part of the contents of the print out } // 4.int Read (byte [] B) from the input data stream up to b.length bytes read into the byte array System.out.println ( "===========" ); // can be seen that a method is available for viewing also the remaining number of bytes is not reading System.out.println (fis.available ()); // 5. the remember to close the stream fis.close (); } }
Second, the source code:
D96_1_CircleRead.java
https://github.com/ruigege66/Java/blob/master/D96_1_CircleRead.java
2.CSDN:https://blog.csdn.net/weixin_44630050
3. Park blog: https: //www.cnblogs.com/ruigege0000/
4. Welcomes the focus on micro-channel public number: Fourier transform public personal number, only for learning exchanges, backstage reply "gifts" to get big data learning materials