try{
File file = new File("\\data\\test.txt");
if(file.isFile()&&file.exists()){
String encoding="";
InputStreamReader read = new InputStreamReader(new FileInputStream(file),encoding);
BufferedReader bufferreader = new BufferedReader(read);
String linText = null;
while((linText = bufferreader.readLine())!=null){
System.out.println(linText);
}
read.close();
}
else{
System.out.println("找不到系统文件");
}
}catch(Exception e){
e.printStackTrace();
}
}
获得文件句柄,把输入流转换成字节流,然后readline输出