Use java.nio for performance, if it's available.