| import java.io.*;
public class Copy {
public static void main(String[] args) throws IOException {
FileReader in = new FileReader(new File(args[0]));
FileWriter out = new FileWriter(new File(args[1]));
int c;
do{
c = in.read();
if(c != -1) out.write(c);
} while (c != -1);
in.close();
out.close();
}
}
|
|
| | Et eksempel hvor tegnene fra én tekstfil kopieres over på en anden.
Navnenen på filen tages fra parameteren til main (en array af String).
Hvis man kører programmet med 'java copy xxx yyy' kopieres filen
xxx til filen yyy.
|