@Test public void getBytesOfNewChannel_shouldReturnTheSameDataAsTheInput() throws IOException { try(GfsSeekableByteChannel channel = new GfsSeekableByteChannel(file, singleton(READ))) { assertArrayEquals(FILE_DATA, channel.getBytes()); } }
@Nonnull public byte[] getBytes() { synchronized(this) { byte[] bytes = new byte[buffer.limit()]; arraycopy(buffer.array(), 0, bytes, 0, bytes.length); return bytes; } }
GfsSeekableByteChannel implements SeekableByteChannel { @Nonnull public byte[] getBytes() { synchronized(this) { byte[] bytes = new byte[buffer.limit()]; arraycopy(buffer.array(), 0, bytes, 0, bytes.length); return bytes; } } }
GfsSeekableByteChannel implements SeekableByteChannel { @Nonnull public byte[] getBytes() { synchronized(this) { byte[] bytes = new byte[buffer.limit()]; arraycopy(buffer.array(), 0, bytes, 0, bytes.length); return bytes; } } GfsSeekableByteChannel(FileNode file, Collection<? extends OpenOption> options); }
GfsSeekableByteChannel implements SeekableByteChannel { @Nonnull public byte[] getBytes() { synchronized(this) { byte[] bytes = new byte[buffer.limit()]; arraycopy(buffer.array(), 0, bytes, 0, bytes.length); return bytes; } } GfsSeekableByteChannel(FileNode file, Collection<? extends OpenOption> options); @Override int read(ByteBuffer dst); @Override int write(ByteBuffer src); @Override long position(); @Override GfsSeekableByteChannel position(long newPosition); @Override long size(); @Override GfsSeekableByteChannel truncate(long size); @Override boolean isOpen(); @Nonnull byte[] getBytes(); @Override void close(); }
GfsSeekableByteChannel implements SeekableByteChannel { @Nonnull public byte[] getBytes() { synchronized(this) { byte[] bytes = new byte[buffer.limit()]; arraycopy(buffer.array(), 0, bytes, 0, bytes.length); return bytes; } } GfsSeekableByteChannel(FileNode file, Collection<? extends OpenOption> options); @Override int read(ByteBuffer dst); @Override int write(ByteBuffer src); @Override long position(); @Override GfsSeekableByteChannel position(long newPosition); @Override long size(); @Override GfsSeekableByteChannel truncate(long size); @Override boolean isOpen(); @Nonnull byte[] getBytes(); @Override void close();  }