|
20 | 20 | */ |
21 | 21 | package org.biojava.nbio.genome.parsers.gff; |
22 | 22 |
|
| 23 | +import java.nio.file.Files; |
| 24 | +import java.nio.file.Path; |
| 25 | +import java.nio.file.Paths; |
23 | 26 | import org.slf4j.Logger; |
24 | 27 | import org.slf4j.LoggerFactory; |
25 | 28 |
|
26 | 29 | import java.io.BufferedReader; |
27 | | -import java.io.FileReader; |
28 | 30 | import java.io.IOException; |
29 | 31 | import java.util.ArrayList; |
30 | 32 | import java.util.List; |
@@ -65,13 +67,23 @@ public class GFF3Reader { |
65 | 67 | * @return A FeatureList. |
66 | 68 | * @throws IOException Something went wrong -- check exception detail message. |
67 | 69 | */ |
68 | | - |
69 | 70 | public static FeatureList read(String filename, List<String> indexes) throws IOException { |
70 | | - logger.info("Reading: {}", filename); |
| 71 | + return read(Paths.get(filename), indexes); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * Read a file into a FeatureList. Each line of the file becomes one Feature object. |
| 76 | + * |
| 77 | + * @param path The path to the GFF file. |
| 78 | + * @return A FeatureList. |
| 79 | + * @throws IOException Something went wrong -- check exception detail message. |
| 80 | + */ |
| 81 | + public static FeatureList read(Path path, List<String> indexes) throws IOException { |
| 82 | + logger.info("Reading: {}", path.toString()); |
71 | 83 |
|
72 | 84 | FeatureList features = new FeatureList(); |
73 | 85 | features.addIndexes(indexes); |
74 | | - BufferedReader br = new BufferedReader(new FileReader(filename)); |
| 86 | + BufferedReader br = Files.newBufferedReader(path); |
75 | 87 |
|
76 | 88 | String s; |
77 | 89 | for (s = br.readLine(); null != s; s = br.readLine()) { |
@@ -103,6 +115,10 @@ public static FeatureList read(String filename) throws IOException { |
103 | 115 | return read(filename,new ArrayList<String>(0)); |
104 | 116 | } |
105 | 117 |
|
| 118 | + public static FeatureList read(Path path) throws IOException { |
| 119 | + return read(path,new ArrayList<String>(0)); |
| 120 | + } |
| 121 | + |
106 | 122 |
|
107 | 123 | /** |
108 | 124 | * create Feature from line of GFF file |
|
0 commit comments