public void fileReader(){
//创建Reader类Reader re=null;
BufferedReader bf=null;
try {
//读取文件
re=new FileReader("E:/ATM.txt");
//套接流,在一个流的基础上,再套接一个流,称为高级流
bf=new BufferedReader(re);
String s=null;
while((s=bf.readLine())!=null){
System.out.println(s);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
bf.close();
re.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public class LearnWrite {
public void write() {
Writer wri = null;
try {
wri = new FileWriter("E:/ATM.txt", true);
wri.write("li ");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
wri.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}