使用了两种方式,个人更倾向于第二种
方法1:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

public class FileOperation {
    
public static void main(String args[]){
        
try{
            
boolean flag=false;
            BufferedReader br
=new BufferedReader(new FileReader((new File("C:/route.txt"))));
            BufferedWriter bw
=new BufferedWriter(new FileWriter((new File("C:/result.txt"))));
            String temp
=br.readLine();
            
while(temp!=null){
                
if(flag){
                    bw.write(
"\r"+"\n"+temp.toUpperCase());
                }
else{
                    bw.write(temp);
                    flag
=true;
                }

                temp
=br.readLine();
            }

            br.close();
            bw.close();
        }
catch(Exception e){
            e.printStackTrace();
        }

    }

}


方法2:
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class FileOperation2 {
    
public static void main(String[] args) throws IOException {
        BufferedInputStream in 
= new BufferedInputStream(new FileInputStream(
                
"C:/route.txt"));
        PrintStream out 
= new PrintStream(new BufferedOutputStream(
                
new FileOutputStream("c:/result.txt")));
        System.setIn(in);
        System.setOut(out);
        BufferedReader br 
= new BufferedReader(new InputStreamReader(System.in));
        String s;
        
boolean flag=false;
        
while ((s = br.readLine()) != null){
            
if(flag){
                System.out.print(
"\r\n"+s.toUpperCase());
            }
else{
                System.out.print(s);
                flag
=true;
            }

        }

        out.close();
    }

}