Hey guys, I'm getting into the whole Input/Output thing in Java and I wrote this example code that I found in my book. I don't know how to use it because I've never tried working with these types of programs before. I've tried writing the name of the file I'm trying to input and I've also tried writing the location of the file I'm trying to input but nothing has seemed to work. Could anyone tell me what I need to write so that it works? (I'm using Windows 7).
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; /* * This program applies line numbers to a file. */ public class LineNumberer { public static void main(String[] args) throws FileNotFoundException { // Prompt the input and the output file names Scanner console = new Scanner(System.in); System.out.println("Input file: "); String inputFileName = console.next(); System.out.println("Output file: "); String outputFileName = console.next(); // Construct the Scanner and PrintWriter objects for reading and writing. File inputFile = new File(inputFileName); Scanner in = new Scanner(inputFile); PrintWriter out = new PrintWriter(outputFileName); int lineNumber = 1; // Read the input and write the output. while (in.hasNextLine()) { String line = in.nextLine(); out.println("/" + lineNumber + " */" + line); lineNumber++; } in.close(); out.close(); } }