Hi guys, can u help me with the coding of java, so i can copy a single file using command prompt.
so, i wanna run the java file from command prompt of windows, like "java "my java script" "my file target"" and make a copy of my "my file target" at the same directory without replace the old one.
please help me?
i came out with this
import java.io.*;
class ReadWrite {
public static void main(String args[]) throws IOException {
FileInputStream fis = new FileInputStream(args[0]);
FileOutputStream fos = new FileOutputStream("output.txt");
int n;
if(args.length != 1)
throw (new RuntimeException("Usage : java ReadWrite <filetoread> <filetowrite>"));
while((n=fis.read()) >= 0)
fos.write(n);
}
}
but the copy of the file is named as output.txt can u guys help me with the coding, if i wanna choose my own output name? if i type "java ReadWrite input.txt (this is the output name that i want)" on command prompt
really need help here...