Tag Archive for Arrays

Arrays.asList() – Why You Should Wrap It

oh noes!
I was trying to get the difference of two lists of files when a wild UnsupportedOperationException appeared!

My code looked a lil’ something like this:

...
List<File> listOfOtherFiles = Arrays.asList(otherDirectory.listFiles());
List<File> fileList = Arrays.asList(directory.listFiles());
fileList.removeAll(listOfOtherFiles);
...

The culprit: Arrays.asList(). Read more