/* The program demonstrate a simple File Input * */ import java.util.*; // Needed for Scanner class import java.io.*; // Needed for File input and output public class FileIn { public static void main(String[] args)throws IOException { Scanner key = new Scanner(System.in); // Opens the file or create a file if it doesn't exist PrintWriter pw = new PrintWriter("Name.txt"); for(int i=0; i<3; i++) { // Gets the name from the user System.out.println("Enter a name: "); String name = key.nextLine(); // Writes the name into the file pw.println(name); } /* Closes the file A step that always need to remember to do * */ pw.close(); } }