I'm using this lambda expression in my code:
File slika = new File(tempPath + File.separator + imena.stream().filter(x -> !x.trim().equals("null")).findFirst().get());
It's supposed to get a name from a file that was posted to my servlet that doesn't equal null. I checked the contents of the ArrayList<String> imena, and found out that it contains the following (separated by commas): null, null, null, Photo0098.jpg. The last one is the one I posted to the server, and the one that is supposed to get picked up by the filter, but instead I get a null pointer exception. That identical piece of code works on another servlet that also handles file uploads. Can someone tell me why my code is not working here, even though it works elsewhere in the same condition?