Skip to content

Instantly share code, notes, and snippets.

@rayjcwu
Created February 25, 2014 08:03
Show Gist options
  • Select an option

  • Save rayjcwu/9204785 to your computer and use it in GitHub Desktop.

Select an option

Save rayjcwu/9204785 to your computer and use it in GitHub Desktop.
public class Solution {
public static void main(String []argv) {
BufferedReader br = new BufferedReader(new FileReader("...."));
boolean prevHasError = false;
int lineNum = 0;
while (br.hasNext()) {
String line = br.readLine();
boolean hasError = (line.indexOf("error") != -1);
if (hasError || prevHasError) {
System.out.println(lineNum + " " + line);
}
prevHasError = hasError;
lineNum++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment