File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
src/main/java/htsjdk/samtools Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 8
8
import java .nio .ByteOrder ;
9
9
import java .nio .MappedByteBuffer ;
10
10
import java .nio .channels .FileChannel ;
11
+ import java .nio .file .StandardOpenOption ;
11
12
12
13
/**
13
14
* Traditional implementation of BAM index file access using memory mapped files.
@@ -16,14 +17,9 @@ class MemoryMappedFileBuffer implements IndexFileBuffer {
16
17
private MappedByteBuffer mFileBuffer ;
17
18
18
19
MemoryMappedFileBuffer (final File file ) {
19
- try {
20
- // Open the file stream.
21
- final FileInputStream fileStream = new FileInputStream (file );
22
- final FileChannel fileChannel = fileStream .getChannel ();
20
+ try (final FileChannel fileChannel = FileChannel .open (file .toPath (), StandardOpenOption .READ );) {
23
21
mFileBuffer = fileChannel .map (FileChannel .MapMode .READ_ONLY , 0L , fileChannel .size ());
24
22
mFileBuffer .order (ByteOrder .LITTLE_ENDIAN );
25
- fileChannel .close ();
26
- fileStream .close ();
27
23
} catch (final IOException exc ) {
28
24
throw new RuntimeIOException (exc .getMessage (), exc );
29
25
}
@@ -51,7 +47,7 @@ public void skipBytes(final int count) {
51
47
52
48
@ Override
53
49
public void seek (final long position ) {
54
- mFileBuffer .position (( int ) position );
50
+ mFileBuffer .position (Math . toIntExact ( position ) );
55
51
}
56
52
57
53
@ Override
You can’t perform that action at this time.
0 commit comments