public static void main(String[] args) throws Exception {
//解决中文乱码
//IO流读取一行
InputStreamReader isr = new InputStreamReader(new FileInputStream("c:/Windows/WindowsUpdate.log"), "UTF-8");
BufferedReader read = new BufferedReader(isr);
while (read.ready()) {
System.out.println(read.readLine());
}
//IO流写入一行
//传入true表示按原文件内容后面追加
OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream("e:test.txt",true),"gb2312");
BufferedWriter bw=new BufferedWriter(osw);
for (int i = 0; i < 10; i++) {
bw.write(new Date().toLocaleString()+"【i="+i+"】");
bw.newLine();
}
bw.flush();
bw.close();
osw.close();
}