Input:
file view In
view in xxx
xxx view In
file xxx In
file view
file view xxx
xxx file in xxx
view in xxx
Output:
xxx view In
file xxx In
file view
file view xxx
package com.codegym.task.task19.task1922;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/*
Searching for the right lines
*/
public class Solution {
public static List<String> words = new ArrayList<>();
static {
words.add("file");
words.add("view");
words.add("In");
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String fileName = br.readLine();
br.close();
FileReader fr = new FileReader(fileName);
BufferedReader br1 = new BufferedReader(fr);
while (br1.ready()) {
String a = br1.readLine();
String[] str = a.split(" ");
int num = 0;
for (String ss :
str) {
if (ss.equals(words.get(0))) {
} else if (ss.equals(words.get(1))) {
num++;
} else if (ss.equals(words.get(2))) {
num++;
}
}
if (num == 2) {
System.out.println(a);
}
}
fr.close();
br1.close();
}
}