|
134 | 134 | */ |
135 | 135 | public final class CSVParser implements Iterable<CSVRecord>, Closeable { |
136 | 136 |
|
| 137 | + /** |
| 138 | + * Creates a parser for the given {@link File}. |
| 139 | + * |
| 140 | + * <p><strong>Note:</strong> This method internally creates a FileReader using |
| 141 | + * {@link java.io.FileReader#FileReader(java.io.File)} which in turn relies on the default encoding of the JVM that |
| 142 | + * is executing the code. If this is insufficient create a URL to the file and use |
| 143 | + * {@link #parse(URL, Charset, CSVFormat)}</p> |
| 144 | + * |
| 145 | + * @param file |
| 146 | + * a CSV file. Must not be null. |
| 147 | + * @param charset |
| 148 | + * A charset |
| 149 | + * @param format |
| 150 | + * the CSVFormat used for CSV parsing. Must not be null. |
| 151 | + * @return a new parser |
| 152 | + * @throws IllegalArgumentException |
| 153 | + * If the parameters of the format are inconsistent or if either file or format are null. |
| 154 | + * @throws IOException |
| 155 | + * If an I/O error occurs |
| 156 | + */ |
| 157 | + public static CSVParser parse(final File file, final Charset charset, final CSVFormat format) throws IOException { |
| 158 | + Assertions.notNull(file, "file"); |
| 159 | + Assertions.notNull(format, "format"); |
| 160 | + return new CSVParser(new InputStreamReader(new FileInputStream(file), charset), format); |
| 161 | + } |
| 162 | + |
137 | 163 | /** |
138 | 164 | * Creates a CSV parser using the given {@link CSVFormat}. |
139 | 165 | * |
@@ -190,32 +216,6 @@ public static CSVParser parse(Reader reader, final CSVFormat format) throws IOEx |
190 | 216 | return new CSVParser(reader, format); |
191 | 217 | } |
192 | 218 |
|
193 | | - /** |
194 | | - * Creates a parser for the given {@link File}. |
195 | | - * |
196 | | - * <p><strong>Note:</strong> This method internally creates a FileReader using |
197 | | - * {@link java.io.FileReader#FileReader(java.io.File)} which in turn relies on the default encoding of the JVM that |
198 | | - * is executing the code. If this is insufficient create a URL to the file and use |
199 | | - * {@link #parse(URL, Charset, CSVFormat)}</p> |
200 | | - * |
201 | | - * @param file |
202 | | - * a CSV file. Must not be null. |
203 | | - * @param charset |
204 | | - * A charset |
205 | | - * @param format |
206 | | - * the CSVFormat used for CSV parsing. Must not be null. |
207 | | - * @return a new parser |
208 | | - * @throws IllegalArgumentException |
209 | | - * If the parameters of the format are inconsistent or if either file or format are null. |
210 | | - * @throws IOException |
211 | | - * If an I/O error occurs |
212 | | - */ |
213 | | - public static CSVParser parse(final File file, final Charset charset, final CSVFormat format) throws IOException { |
214 | | - Assertions.notNull(file, "file"); |
215 | | - Assertions.notNull(format, "format"); |
216 | | - return new CSVParser(new InputStreamReader(new FileInputStream(file), charset), format); |
217 | | - } |
218 | | - |
219 | 219 | /** |
220 | 220 | * Creates a parser for the given {@link String}. |
221 | 221 | * |
|
0 commit comments