以下所有对象需要关闭(close)的,都使用jdk1.7的try-with-resource来进行释放
String path = "D:\\xxx\\xxxxx\\xxxxx.txt";
File file = new File(path);
FileInputStream fileStream = new FileInputStream(file);
InputStreamReader inReader = new InputStreamReader(fileStream,"UTF-8");
BufferedReader bfReader = new BufferedReader(inReader);
String content = "";
while((content = bfReader.readLine()) != null){
//对于content
}
String path = "D:\\xxx\\xxxxx\\xxxxx.txt";
File file = new File(path);
FileOutPutStream fileStream = new FileOutputSream(file);
OutPutStreamWriter ows = new OutPutSreamWriter(fileStream);
ows.write("要输出的字符串");
//write默认不换行,如果要换行,可以通过"\n"进行换行