replaced legacy IO code with java.nio