java文件操作(读流)
try{
InputStream is = new FileInputStream("abc.txt");
InputStreamReader ir = new InputStreamReader(is);
BufferedReader br = new BufferedReader(ir);
String line = null;
List<String> list = new ArrayList<String>();
while((line = br.readLine())!=null){
System.out.println(line);
list.add(line);
}
//将abc.txt文件中的内容写入到chen.txt中
OutputStream os = new FileOutputStream("chen.txt");
OutputStreamWriter or = new OutputStreamWriter(os);
PrintWriter pw = new PrintWriter(or);
Iterator it = list.iterator();
while(it.hasNext()){
pw.println(it.next());
}
pw.flush();
pw.close();
}catch(Exception e){
e.printStackTrace();
}