changed use of java.nio to make it work in Java 1.6