Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.example;
- import java.io.*;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws IOException {
- String source_filename = "D://Hello.txt";
- String target_filename = "D://Hello.txt";
- System.out.println("请输入源文件地址 ");
- source_filename = ( new Scanner(System.in)).nextLine();
- System.out.println("请输入目标文件地址 ");
- target_filename = ( new Scanner(System.in)).nextLine();
- FileReader fr = new FileReader(source_filename);
- BufferedReader br = new BufferedReader(fr);
- FileWriter fw = new FileWriter(target_filename, true);
- BufferedWriter bw = new BufferedWriter(fw);
- String line;
- while((line = br.readLine())!=null){
- bw.write(line);
- bw.newLine();
- System.out.println(line);
- }
- bw.flush();
- br.close();
- fr.close();
- bw.close();
- fw.close();
- }
- }
Advertisement
Advertisement