copyfile.java

来自「ssd3的教程 是我们老师给我们的 纯英文 有兴趣的可以」· Java 代码 · 共 55 行

JAVA
55
字号
import  java.io.*;

/**
 * Makes a copy of a file.
 *
 * @author  author name
 * @version  1.0
 */
public class CopyFile  {

    /* Standard input stream */
    private static BufferedReader  stdIn =
        new BufferedReader(new  InputStreamReader(System.in));

    /* Standard output stream */
    private static PrintWriter  stdOut =
        new PrintWriter(System.out, true);

    /* Standard error stream */
    private static PrintWriter  stdErr =
        new PrintWriter(System.err, true);

    /**
     * Makes a copy of a file.
     *
     * @param args  not  used.
     * @throws IOException  If an I/O error occurs.
     */
    public static void  main(String[]  args) throws IOException  {

        stdErr.print("Source filename:  ");
        stdErr.flush();

        BufferedReader  input =
            new BufferedReader( new FileReader(stdIn.readLine()));

        stdErr.print("Destination filename:  ");
        stdErr.flush();

        PrintWriter  output =
            new  PrintWriter(new FileWriter(stdIn.readLine()));

        String  line = input.readLine();

        while (line != null)  {
            output.println(line);
            line = input.readLine();
        }

        input.close();
        output.close();

        stdOut.println("done");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?