public String read() { String r; final char[] buf = new char[1024]; final StringBuilder b = new StringBuilder(); int n; init(); try { while ((n = this.bufreader.read(buf)) >= 0) { b.append(buf, 0, n); } } catch (Exception e) { /* can't happen */ } r = b.toString(); if (this.shift != null) { // replace all but last \n .. Matcher m = makeregex("\n\\z").matcher(r); if (m.find()) { r = r.substring(0, m.start()); r = r.replaceAll("\n", "\n" + this.shift); r = r + "\n"; } else { r = r.replaceAll("\n", "\n" + this.shift); } r = this.shift + r; } return r; }
/* * Read the next line. Ignores comment lines and empty lines if desired. * * @see java.io.BufferedReader#readLine() */ public String readLine() { String line; init(); try { line = this.bufreader.readLine(); while (line != null && this.ignore(line)) { line = this.bufreader.readLine(); } } catch (IOException e) { line = null; } if (line != null && this.shift != null) { line = this.shift + line; } return line; }