- #1
camel-man
- 76
- 0
Im using Eclipse and I have an input file name that I am reading from but for some reason when the program ends there is no output file that gets created? Does anyone know what I am doing wrong here?
Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class NameAgeReverse{
public static void main(String[] args) throws FileNotFoundException
{
Scanner enter = new Scanner(System.in);
String inputFile, outputFile;
File input;
PrintWriter output;
System.out.println("Input file: ");
inputFile= enter.nextLine();
System.out.println("Output file: ");
outputFile= enter.nextLine();
input = new File(inputFile);
Scanner in = new Scanner(input);
output = new PrintWriter(outputFile);
while(in.hasNextLine()){
String name = in.nextLine();
output.println(name);
}
in.close();
output.close();
}
}