I have this simple and I am trying to find the string all
and after finding it it should jump to next line and look for the integer value 30
and store it in Integer variable.
Simple:
spoon 05:09 05:39 06:11 06:41 07:11 07:41 08:11 17:11 17:41 18:11 18:41 19:11 19:41
apple 05:09 05:39 06:11 06:41 07:11 07:41 08:11 all 17:11 17:41 18:11 18:41 19:11 19:41
chair 05:11 05:41 06:14 06:44 30 07:14 07:44 08:14 17:14 17:44 18:14 18:44 19:14 19:44
table 05:13 05:43 06:17 06:47 07:17 07:47 08:17 Min 17:17 17:47 18:17 18:47 19:17 19:47
Code:
Scanner scanner = new Scanner(file)) {
int lineNum = 0;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
lineNum++;
if(line.contains(" all ")){
//go to the next line and find the integer value 30 then store it.
System.out.println("I found it on line " +lineNum);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…