Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<DispLine> sequential() throws Exception {
- List<DispLine> disps = new ArrayList<>();
- int nlIndex = 0; // index of start of next line
- int disp = 0; // byte displacement of current line
- int lineNumber = 0;
- while(true) {
- char currentChar;
- StringBuilder sb = new StringBuilder();
- while ((currentChar = (char)br.read()) != (char)-1 && currentChar != '\n') {
- sb.append(currentChar);
- nlIndex++;
- }
- if (currentChar ==(char)-1) {
- break;
- } else {
- String line = sb.toString();
- if (patt.matcher(line).find())
- disps.add(new DispLine(disp, line));
- final int currentLineLength = nlIndex - disp + 1;
- disp += currentLineLength;
- nlIndex = disp;
- }
- lineNumber++;
- if (lineNumber % 1_000_000 == 0) System.out.println(lineNumber);
- }
- return disps;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement