package com.javarush.task.task19.task1922;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Ищем нужные строки
*/
public class Solution {
public static List<String> words = new ArrayList<String>();
static {
words.add("файл");
words.add("вид");
words.add("В");
}
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file = reader.readLine();
reader.close();
ArrayList<Word> list = new ArrayList<>();
BufferedReader reader1 = new BufferedReader(new FileReader(file));
List<String> list1 = new ArrayList<>();
int count;
while (reader1.ready()) {
String str = reader1.readLine();
String[] masstr = str.split("\\s");
list1.clear();
for (int i = 0; i < masstr.length; i++) {
list1.add(masstr[i].replaceAll("\\uFEFF", ""));
}
count = 0;
if (!list1.containsAll(words)) {
for (String s : list1) {
if (words.contains(s)) {
count++;
}
Word word = new Word(str, count);
list.add(word);
}
}
}
reader1.close();
HashMap<String, Integer> map = new HashMap<>();
for (Word w: list) {
map.put(w.str, w.count);
}
for (Map.Entry pair: map.entrySet()) {
if ((int)pair.getValue()!=0 && (int)pair.getValue()!=1){
System.out.println(pair.getKey());}
}
}
public static class Word {
String str;
int count;
public Word(String str, int count) {
this.str = str;
this.count = count;
}
}
}
package com.javarush.task.task19.task1922;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Ищем нужные строки
*/
public class Solution {
public static List<String> words = new ArrayList<String>();
static {
words.add("файл");
words.add("вид");
words.add("В");
}
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file = reader.readLine();
reader.close();
ArrayList<Word> list = new ArrayList<>();
BufferedReader reader1 = new BufferedReader(new FileReader(file));
List<String> list1 = new ArrayList<>();
int count;
while (reader1.ready()) {
String str = reader1.readLine();
String[] masstr = str.split("\\s");
list1.clear();
for (int i = 0; i < masstr.length; i++) {
list1.add(masstr[i].replaceAll("\\uFEFF", ""));
}
count = 0;
if (!list1.containsAll(words)) {
for (String s : list1) {
if (words.contains(s)) {
count++;
}
Word word = new Word(str, count);
list.add(word);
}
}
}
reader1.close();
HashMap<String, Integer> map = new HashMap<>();
for (Word w: list) {
map.put(w.str, w.count);
}
for (Map.Entry pair: map.entrySet()) {
if ((int)pair.getValue()!=0 && (int)pair.getValue()!=1){
System.out.println(pair.getKey());}
}
}
public static class Word {
String str;
int count;
public Word(String str, int count) {
this.str = str;
this.count = count;
}
}
}