public void readFile(String path, Interfaces.Callback<ByteBuffer> cb) { Path file = Paths.get(path); AsynchronousFileChannel channel = openFileChannel(cb, file); if (channel == null) { return; } eventLoop.runInBackground(() -> Files.size(file), makeReader(channel, true, 0, cb)); }
public void readFile(String path, String encoding, Interfaces.Callback<String> cb) { Path file = Paths.get(path); AsynchronousFileChannel channel = openFileChannel(cb, file); if (channel == null) { return; } eventLoop.runInBackground( () -> Files.size(file), makeReader( channel, true, 0, (err, buffer) -> { Charset charset = Charset.forName(encoding); cb.invoke(null, new String(buffer.array(), 0, buffer.position(), charset)); })); }