help
package com.codegym.task.task19.task1922;
import java.io.*;
import java.util.ArrayList;
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) {
String inputFile = "";
int wordCounter = 0;
try(BufferedReader bf = new BufferedReader(new InputStreamReader(System.in))){
inputFile = bf.readLine();
}catch (IOException e){}
//System.out.println("Words matched : "+worldCounter);
try(FileReader file = new FileReader(inputFile)){
StringBuilder builder = new StringBuilder();
while(file.ready()){
char[] cbuf = new char[900];
file.read(cbuf);
String line = new String(cbuf);
builder.append(line);
line = line.trim();
line = line.replaceAll("\r\n"," ");
String[] lineArr = line.split(" ");
for(String word : words){
for(String s1 : lineArr){
//System.out.println("Word : "+word+" s1 : "+s1);
// boolean c = s1.equals(word);
//System.out.println("c : "+c);
if(s1.equals(word)){
wordCounter = wordCounter+1;
// System.out.println("WordCounter : "+wordCounter);
}
}
}
}
if(wordCounter == 2){
System.out.println(builder.toString());
}
}catch (IOException e){}
}
static int indexCount(String str,String strFind){
int count = 0,fromIndex = 0;
while ((fromIndex = str.indexOf(strFind, fromIndex)) != -1 ){
//System.out.println("Found at index: " + fromIndex);
count++;
fromIndex++;
}
return count;
}
}