Skip to content

Commit 23887e8

Browse files
committed
BytesLocation: add ctor with initial capacity
This makes it easier to create BytesHandles on the fly: bytes = dataHandleService.create(new BytesLocation(512)); instead of: bytes = dataHandleService.create( new BytesLocation(ByteBuffer.allocate(512)));
1 parent d2b23dc commit 23887e8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/org/scijava/io/BytesLocation.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public BytesLocation(final byte[] bytes, final int offset, final int length) {
6060
this(ByteBuffer.wrap(bytes, offset, length));
6161
}
6262

63+
/**
64+
* Creates a {@link BytesLocation} backed by a {@link ByteBuffer} with the
65+
* specified initial capacity.
66+
*/
67+
public BytesLocation(final int initialCapacity) {
68+
this(ByteBuffer.allocate(initialCapacity));
69+
}
70+
6371
// -- BytesLocation methods --
6472

6573
/** Gets the associated {@link ByteBuffer}. */

0 commit comments

Comments
 (0)