RunParser now reads from file instead of stdin.

This commit is contained in:
Jakob Herrmann 2017-02-21 22:19:00 +01:00
parent 40d87c8636
commit 72bf03ec58

View File

@ -9,6 +9,8 @@ import de.dhbwstuttgart.syntaxtree.modifier.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.IOException;
@ -16,7 +18,8 @@ import java.nio.charset.StandardCharsets;
public class RunParser{
public static void main(String[] args){
try{
Scanner sc = new Scanner(System.in);
File file = new File(args[0]);
Scanner sc = new Scanner(file);
String inputString = sc.nextLine();
while(sc.hasNextLine()) inputString = inputString + sc.nextLine() + "\n";
InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8));
@ -45,6 +48,9 @@ public class RunParser{
catch(java.util.NoSuchElementException e){
System.out.println("Error: Source seems to be empty.");
}
catch(FileNotFoundException e){
System.out.println("File not found.");
}
catch(IOException e){
System.out.println("An exception occured which is on our TODO list.");
e.printStackTrace();