Skip to content

Commit 35594ef

Browse files
Add GFF3Reader overload that accepts Path
The String-based functions are still here, and almost all the code is shared. The Path overload allows us to read files via NIO providers, such as e.g. the GCS NIO provider for reading files on Google Cloud Storage.
1 parent b9519e4 commit 35594ef

File tree

1 file changed

+13
-2
lines changed
  • biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff

1 file changed

+13
-2
lines changed

biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/GFF3Reader.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
package org.biojava.nbio.genome.parsers.gff;
2222

23+
import java.nio.file.Files;
24+
import java.nio.file.Path;
25+
import java.nio.file.Paths;
2326
import org.slf4j.Logger;
2427
import org.slf4j.LoggerFactory;
2528

@@ -67,11 +70,15 @@ public class GFF3Reader {
6770
*/
6871

6972
public static FeatureList read(String filename, List<String> indexes) throws IOException {
70-
logger.info("Reading: {}", filename);
73+
return read(Paths.get(filename), indexes);
74+
}
75+
76+
public static FeatureList read(Path path, List<String> indexes) throws IOException {
77+
logger.info("Reading: {}", path.toString());
7178

7279
FeatureList features = new FeatureList();
7380
features.addIndexes(indexes);
74-
BufferedReader br = new BufferedReader(new FileReader(filename));
81+
BufferedReader br = Files.newBufferedReader(path);
7582

7683
String s;
7784
for (s = br.readLine(); null != s; s = br.readLine()) {
@@ -103,6 +110,10 @@ public static FeatureList read(String filename) throws IOException {
103110
return read(filename,new ArrayList<String>(0));
104111
}
105112

113+
public static FeatureList read(Path path) throws IOException {
114+
return read(path,new ArrayList<String>(0));
115+
}
116+
106117

107118
/**
108119
* create Feature from line of GFF file

0 commit comments

Comments
 (0)