Skip to content

Commit ee76b7c

Browse files
authored
Merge pull request #355 from scijava/default-text-service-open
DefaultTextService: use try-with-resources
2 parents 8e65de4 + f105c73 commit ee76b7c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/main/java/org/scijava/text/DefaultTextService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,12 @@ public final class DefaultTextService extends
6363
@Override
6464
public String open(final File file) throws IOException {
6565
// This routine is from: http://stackoverflow.com/a/326440
66-
final FileInputStream stream = new FileInputStream(file);
67-
try {
66+
try (final FileInputStream stream = new FileInputStream(file)) {
6867
final FileChannel fc = stream.getChannel();
6968
final MappedByteBuffer bb =
7069
fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
7170
return Charset.defaultCharset().decode(bb).toString();
7271
}
73-
finally {
74-
stream.close();
75-
}
7672
}
7773

7874
@Override

0 commit comments

Comments
 (0)