public class read1 {
public static void main(String[] args) throws IOException {
FileInputStream in = new FileInputStream("a");
int len = 0;
while((len = in.read()) != -1) {
System.out.print((char)len);
}
in.close();
}
}
一次读取一个字节数组
注意:String导包出错也会出错。
public class read1 {
public static void main(String[] args) throws IOException {
FileInputStream in = new FileInputStream("a");
int len = 0;
byte[] bytes = new byte[1024];
while((len = in.read(bytes)) != -1) {
System.out.println(new String(bytes));
}
in.close();
}
}