Java 6 compatible fix without nio.
Would make sense to adjust it once 7 is available.