what i will do is ask the user to specify a path which they want to create the file. The program can be written in a few ways, i.e. using different class, they are gernally three of them, FileWriter, BufferedWriter and PrintWriter, in here i will use PrintWriter, because this is the easiest way.
public class Write{
public static void main(String[] args) throws IOException{
//to use the PrintWriter class which must pass in a FileWriter object as parameter
PrinteWriter pr = new PrintWriter(new FileWriter(agrs[0])); /*args[0] is the first file name specified by the user in the command line, if the file name doesnt exist, it will create a new one*/
pr.println("Whatever you wanna type.");
pr.print("Pretty much the same as using System.out.");
pr.close(); // this is very important
}
}