I have the following program:
public static void main(String args[]) {
File origen = new File("C:\Users\Montse\Documents\NetBeansProjects\Copiar2\hola.txt");
File destino = new File("C:\Users\Montse\Documents\NetBeansProjects\Copiar2\backupVisibles\hola.txt");
try {
InputStream in = new FileInputStream(origen);
OutputStream out = new FileOutputStream(destino);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException ioe){
ioe.printStackTrace();
}
}
I can not see how to get the following:
I need to Argument [0] the argument of the current directory.
that is: String sDirectory="C: \ Users \ Montse \ Documents \ NetBeansProjects \ Copy2"; File f = new File (sDirectory);
and copy the file that I put in the parameter args [1] for example the file hello.txt
The most I have achieved is this program that basically what it does is copy a file from one folder to another, but I do not get what I really need ..: (
thanks!
PS: I add text because I think I have not explained myself completely well.
That is, with the first ARGS [0] I need you to put the current directory. In the second ARGS [1] I need that X file for example the file hello.txt (that is to say I will put it in the parameters that I choose ..)
And that file will be saved in the folder that I want.