1 package nl.chess.it.util.config.resolv; 2 3 import java.io.BufferedReader; 4 import java.io.IOException; 5 import java.io.InputStream; 6 import java.io.InputStreamReader; 7 8 /*** 9 * @author Guus Bosman (Chess-iT) 10 */ 11 public class PropertyInputStreamValidator { 12 13 public static void validate(InputStream inStream) throws IOException { 14 BufferedReader in = new BufferedReader(new InputStreamReader(inStream, "8859_1")); 15 int lineNumber = 0; 16 while (true) { 17 String line = in.readLine(); 18 lineNumber++; 19 if (line == null) return; 20 21 for (int i = 0; i < line.length(); i++) { 22 if (line.charAt(i) == '//') { 23 if (i < line.length()) { 24 if (!isAllowedEscape(line.charAt(i + 1))) { 25 throw new IOException("Invalid escape sequence (//" +line.charAt(i + 1) + ") in InputStream on line " +lineNumber + ": " + line); 26 } 27 } 28 } 29 } 30 31 } 32 } 33 34 private static boolean isAllowedEscape(char c) { 35 if ("//tnfr\"'u".indexOf(c) >= 0) return true; 36 37 return false; 38 } 39 }