Sep 8, 2018 12:00 PM
(This post was last modified: Sep 8, 2018 01:31 PM by hoobahstank.)
EDIT: Just figured out one problem. Now how do i manage to use this input to now send this to an output file in a formatted way? I need to use printstream but will i put it within the try statement?
Code
import java.io.File;
import java.io.FileReader;
import java.util.Scanner;
public class Standalonereport {
public static void main(String[] args) {
String fileName;
String outFile;
Scanner keyboardScanner = new Scanner(System.in);
System.out.printf("Enter the file name: ");
fileName = keyboardScanner.next();
System.out.printf("Enter the output file name: ");
outFile = keyboardScanner.next();
try
{
Scanner inputScanner = new Scanner(new File(fileName));
while (inputScanner.hasNextLine())
{
String i = inputScanner.nextLine();
System.out.println(i);
}
inputScanner.close();
} catch (Exception e) {
System.out.println("Exception");
e.printStackTrace();
}
}
}
