From 72bf03ec581ae4401d8212abb773d6393f860780 Mon Sep 17 00:00:00 2001 From: Jakob Herrmann Date: Tue, 21 Feb 2017 22:19:00 +0100 Subject: [PATCH] RunParser now reads from file instead of stdin. --- src/de/dhbwstuttgart/parser/RunParser.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index 08228eb0..f9456a85 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -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();