I have been banging my head against the wall about this for quite some time now and would really appreciate some help.
I have 2 streams and what I want is to exclude elements from one stream if they are in the other stream.
I am trying to write a program to find all audio files and then writes them to a file. You give it a folder to check and it finds all the audio files in that folder and writes them all to a file. That part works great. The problem comes into play if you give it the same folder again, I want to be able to exclude the audio files that are already there. Here is the code in question:
Stream<Path> s = Files.walk(folder.toPath()).filter(p -> isAudio(p));
and then the isAudio(Path p) method:
try
{
if (Files.probeContentType(p).startsWith("audio"))
{
if (PS != null)
{
System.out.println("boo");
System.out.println(PS.noneMatch(t -> t.equals(p.toString())));
System.out.println("boo2");
}
return true;
}
}
catch (Exception e) {System.err.println(e); }
return false;
PS is my second stream and it read in from the file. I have tested it and it is correct. my problem is that the results of the noneMatch aren't printed and "boo2" is NEVER displayed. It gets skipped every single time. It jumps to "return false;" every single time and I am completely lost for an answer. Please, any help I can get would be greatly appreciated!!