| 1 | package uk.co.zonetora; |
| 2 | import java.io.BufferedReader; |
| 3 | import java.io.IOException; |
| 4 | import java.io.InputStreamReader; |
| 5 | |
| 6 | public class InputParser { |
| 7 | |
| 8 | private static final String delim = "--------------------------------------------------------------------------------"; |
| 9 | |
| 10 | public static void parse(RunnableWithString code) throws IOException { |
| 11 | StringBuilder sb = new StringBuilder(); |
| 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 13 | |
| 14 | String cLine; |
| 15 | do { |
| 16 | cLine = br.readLine(); |
| 17 | if(cLine == null || cLine.equals(delim) ) { |
| 18 | String res = code.run(sb.toString()); |
| 19 | if(res != null) { |
| 20 | System.err.println(res); |
| 21 | } |
| 22 | System.err.println(delim); |
| 23 | sb = new StringBuilder(); |
| 24 | } else { |
| 25 | sb.append(cLine).append('\n'); |
| 26 | } |
| 27 | } while (cLine != null); |
| 28 | } |
| 29 | |
| 30 | } |