import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class Test01 {
public static void main(String[] args) throws FileNotFoundException {
FileInputStream fis=new FileInputStream("D:\\新建文件夹\\你若还在.txt");
byte[] bytes=new byte[1024];
/*try {
int date = fis.read(bytes);
String temp=new String(bytes, 0, date);
System.out.println(temp);
} catch (IOException e) {
e.printStackTrace();
}*/
//当别的文档输入时,之前文本文档内容被替换
try {
int date=fis.read(bytes);
while(date!=-1){
String temp=new String(bytes, 0, date);
System.out.println(temp);
date=fis.read(bytes);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
时间: 2024-10-27 18:22:19