Hi guys, could anyone tell me why my code cannot input contents into the file, thanks in advance.
import java.io.*;
import java.util.Scanner;
public class FileIO {
/**
* @param args
*/
public static void main(String[] args) {
// public void writeToFile(){
try {
File outFile = new File(args[0] + ".txt");
PrintWriter out = new PrintWriter(outFile);
Scanner input = new Scanner(System.in);
System.out.print("Input the content save to the file: ");
while (input.hasNext()) {
out.print(input.next());
out.println();
}
out.close();
System.out.println("input to file successfully");
} catch (FileNotFoundException e) {
System.out.println("The file not found.");
}
}
}