Basically I have to do the following: 1)Read the CSV input file. 2)Filter the CSV data based on the blacklist. 3)Sort the input based on the country names in ascending order. 4)Print the records which are not blacklisted. The CSV file contains: id,country-short,country 1,AU,Australia 2,CN,China 3,AU,Australia 4,CN,China The blacklist file contains: AU JP And the desired output is 2,CN,China 4,CN,China
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StreamProcessing {
public static void filterCsv(String fileName, String blacklistFile){
try (Stream<String> stream1 = Files.lines(Paths.get(fileName))) {
Stream<String> stream2 = Files.lines(Paths.get(blacklistFile));
Optional<String> hasBlackList = stream1.filter(s->s.contains(stream2)).findFirst();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String args[])
{
StreamProcessing sp = new StreamProcessing();
sp.filterCsv("Data.csv","blacklist.txt");
}
}
I want to remove the entries that are present in second Stream from comparing from the first Stream without converting it into an array?