代码如下:
package InstreamPack;import java.io.FileInputStream;
import java.io.IOException;public class FileInputStreamDemo01 {public static void main(String[] args) throws IOException {FileInputStream fis = new FileInputStream("D:\\JavaDemo\\java.txt");int by;while((by = fis.read())!=-1){System.out.print((char)by);}fis.close();}}
代码如下:
package InstreamPack;import java.io.FileInputStream;
import java.io.IOException;public class FileInputStreamDemo02 {public static void main(String[] args) throws IOException {FileInputStream fis = new FileInputStream("D:\\JavaDemo\\java.txt");byte[] bys = new byte[1024];int len;while((len=fis.read(bys))!=-1){System.out.print(new String(bys,0,len));}fis.close();}
}