args is an array.
If you try to save the array as it is to a file you will get only the args.toString() content wich in this case is the description of the array.
To write the CONTENT, you must use the index.
This is the method I wrote for my personal use:
public static void saveToFile (String filename, String[] fileContent, boolean doOutput) {
saveToFile (new File (filename), fileContent, doOutput);
}
public static void saveToFile (File file, String[] fileContent, boolean doOutput) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, false)));
if (doOutput)
System.out.print ("Writing ");
for (int i = 0; i < fileContent.length; i++) {
out.println(fileContent[i]);
if (doOutput)
System.out.print (".");
}
if (doOutput)
System.out.println (" done");
out.close();
} catch (IOException e) {
System.out.println("I/O Error: " + e.getMessage());
}
}
Instead of using the index, with the new Java version you should be able to use the following trick:
public static void saveToFile (File file, String[] fileContent, boolean doOutput) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, false)));
if (doOutput)
System.out.print ("Writing ");
for (String line : fileContent) { //This is the for-each construct: it does exactly the same as the for-to statement shown abowe. In addition, it assigns line = fileContent[i]
out.println(line);
if (doOutput)
System.out.print (".");
}
if (doOutput)
System.out.println (" done");
out.close();
} catch (IOException e) {
System.out.println("I/O Error: " + e.getMessage());
}
}