import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.PrintWriter; import java.util.Scanner; import javax.swing.JFileChooser; /** * @author ernie */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // Ask user for name of input file Scanner console = new Scanner(System.in); //System.out.println("Input file: "); //abcString inputFileName = console.next(); // Ask user for name of output file System.out.println("Output file: "); String outputFileName = console.next(); FileReader reader = null; PrintWriter out = null; try { // set a FileReader object using the name of the input file // selected from a menu JFileChooser chooser = new JFileChooser(); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File selectedFile = chooser.getSelectedFile(); reader = new FileReader(selectedFile); } // set a PrintWriter object named out using the name of the output file out = new PrintWriter(outputFileName); } catch (FileNotFoundException e) { //in case the files aren't found we stop the program System.out.println("File not found!"); // Stop program if no file found System.exit(0); } // construct a Scanner object named in using the object named reader Scanner in = new Scanner(reader); int lineNumber = 1; while (in.hasNextLine()) { String line = in.nextLine(); out.println("/* " + lineNumber + " */ " + line); lineNumber++; } out.close(); } }