@Override public FileChannel open(String mode) { FileMemData obj = getMemoryFile(); return new FileMem(obj, "r".equals(mode)); }
@Override public FileChannel truncate(long newLength) throws IOException { // compatibility with JDK FileChannel#truncate if (readOnly) { throw new NonWritableChannelException(); } if (newLength < size()) { data.touch(readOnly); pos = Math.min(pos, newLength); data.truncate(newLength); } return this; }
@Override public InputStream newInputStream() { FileMemData obj = getMemoryFile(); FileMem m = new FileMem(obj, true); return new FileChannelInputStream(m, true); }
@Override public OutputStream newOutputStream(boolean append) throws IOException { FileMemData obj = getMemoryFile(); FileMem m = new FileMem(obj, false); return new FileChannelOutputStream(m, append); }