Skip to content

Commit 2fd0e37

Browse files
ctruedengab1one
authored andcommitted
DataHandle: add a mutator for the length
In SCIFIO and Bio-Formats, this was a feature of the AbstractNIOHandle. But there is no reason to limit it to NIO-flavored handles only.
1 parent bbb5172 commit 2fd0e37

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ public interface DataHandle<L extends Location> extends WrapperPlugin<L>,
6565
/** Returns the length of the stream. */
6666
long length() throws IOException;
6767

68+
/**
69+
* Sets the new length of the handle.
70+
*
71+
* @param length New length.
72+
* @throws IOException If there is an error changing the handle's length.
73+
*/
74+
void setLength(long length) throws IOException;
75+
6876
/**
6977
* Returns the current order of the stream.
7078
*

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public long length() throws IOException {
8282
return raf().length();
8383
}
8484

85+
@Override
86+
public void setLength(final long length) throws IOException {
87+
raf().setLength(length);
88+
}
89+
8590
@Override
8691
public int read() throws IOException {
8792
return raf().read();

0 commit comments

Comments
 (0)