List of usage examples for java.util.regex PatternSyntaxException getMessage
public String getMessage()
From source file:sorcer.core.provider.logger.RemoteLoggerManager.java
public String getLogComments(String filename) { Pattern p = null;//from ww w.j av a 2 s . com try { // The following pattern lets this extract multiline comments that // appear on a single line (e.g., /* same line */) and single-line // comments (e.g., // some line). Furthermore, the comment may // appear anywhere on the line. p = Pattern.compile(".*/\\*.*\\*/|.*//.*$"); } catch (PatternSyntaxException e) { System.err.println("Regex syntax error: " + e.getMessage()); System.err.println("Error description: " + e.getDescription()); System.err.println("Error index: " + e.getIndex()); System.err.println("Erroneous pattern: " + e.getPattern()); } BufferedReader br = null; StringBuffer bw = new StringBuffer(); try { FileReader fr = new FileReader(filename); br = new BufferedReader(fr); Matcher m = p.matcher(""); String line; while ((line = br.readLine()) != null) { m.reset(line); if (m.matches()) /* entire line must match */ { bw.append(line + "\n"); } } } catch (IOException e) { System.err.println(e.getMessage()); } finally // Close file. { try { if (br != null) br.close(); } catch (IOException e) { } } return bw.toString(); }