package com.houde;
import java.io.*;
public class DemoIO01 {
public static void main(String[] args) {
FileWriter fw=null;
FileReader fr=null;
// TODO Auto-generated method stub
try {
fw=new FileWriter("c://a.txt");
fw.write("abcedfghijklmnopqrstuvwxyz");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
if(fw!=null)
try {
fw.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
}
try {
fr=new FileReader("c:\\a.txt");
//fr.read();
int ch=0;
while((ch=fr.read())!=-1){
System.out.print((char)fr.read());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if(fw!=null)
fw.close();
if(fr!=null)
fr.close();
} catch (IOException e2) {
// TODO: handle exception
System.out.println(e2.toString());
}
}
}
}
输出的是:befhjlnprtvxz
为什么输出的不是:abcedfghijklmnopqrstuvwxyz
|