import java.io.*;
public class CopyFile {
public static void main(String args[]) throws IOException {
FileReader in = null;
FileWriter out = null;
try {
in = new FileReader("input.txt");
out = new FileWriter("output.txt");
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
}finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}
Here is my code
It can only read a text named'input.txt'
when I run it. it can be
$javac CopyFile.java
$java CopyFile
But my TA need me todo something like this.
You must write a makefile document which creates a executable file named CopyFile.
Your program is required to take the input file name as an argument. Following is an example of a program that read from a file named file_name.
$CopyFile file_name
I googled 'how to write a makefile' and 'java read a file and output a file'.
But found nothing like this situation.
It is not $java CopyFile
, it is $CopyFile file_name
the CopyFile
become something like java
. Can someone teach me how to do this or how to google it? I even don't know what is the key word related to this situation to google it...