1. Did you test this?
2. Why not just use ```sortedName.toURI().toString()``` instead of ```"file://" + imageDirectory + folder + "/" + sortedName.getName()```?