Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1.     public List<DispLine> sequential() throws Exception {
  2.         List<DispLine> disps = new ArrayList<>();
  3.         int nlIndex = 0;        // index of start of next line
  4.         int disp = 0;           // byte displacement of current line
  5.         int lineNumber = 0;
  6.         while(true) {
  7.             char currentChar;
  8.             StringBuilder sb = new StringBuilder();
  9.             while ((currentChar = (char)br.read()) != (char)-1 && currentChar != '\n') {
  10.                 sb.append(currentChar);
  11.                 nlIndex++;
  12.             }
  13.             if (currentChar ==(char)-1) {
  14.                 break;
  15.             } else {
  16.                 String line = sb.toString();
  17.                 if (patt.matcher(line).find())
  18.                     disps.add(new DispLine(disp, line));
  19.                 final int currentLineLength = nlIndex - disp + 1;
  20.                 disp += currentLineLength;
  21.                 nlIndex = disp;
  22.             }
  23.             lineNumber++;
  24.             if (lineNumber % 1_000_000 == 0) System.out.println(lineNumber);
  25.         }
  26.         return disps;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement