public static void main(String[] args)throws Exception
{
//1.指定要读 的文件目录及名称
String path="D:/mygrx/practice/test.txt";
File file=new File(path);
//2.创建文件读入流对象
FileInputStream fis=new FileInputStream(file);
// 根据文件创建文件的输入流
InputStreamReader isr=new InputStreamReader(fis,"utf-8");
//读取文件
BufferedReader br=new BufferedReader(isr);
StringBuffer line=new StringBuffer();
String str=null;
File file1=new File("D:/mygrx/practice/aa.txt");
FileOutputStream fos=new FileOutputStream(file1);
OutputStreamWriter osw=new OutputStreamWriter(fos,"utf-8");
BufferedWriter bw=new BufferedWriter(osw);
while((str=br.readLine())!=null){
bw.write(str);
bw.write("\n");
line.append(str);
line.append("\n");
}
System.out.println(line);
bw.flush();
bw.close();
}