|
1 | 1 | package de.siegmar.fastcsv.reader; |
2 | 2 |
|
3 | 3 | import java.io.IOException; |
4 | | -import java.io.InputStreamReader; |
5 | | -import java.io.Reader; |
6 | | -import java.nio.charset.Charset; |
7 | 4 | import java.nio.file.Files; |
8 | 5 | import java.nio.file.Path; |
9 | 6 | import java.nio.file.StandardOpenOption; |
@@ -90,26 +87,4 @@ static Optional<BomHeader> detectCharset(final Path file) |
90 | 87 | } |
91 | 88 | } |
92 | 89 |
|
93 | | - /// Opens a Reader for the given file, skipping a BOM header if present. |
94 | | - /// If no BOM header is present, the `defaultCharset` is used. |
95 | | - /// |
96 | | - /// @param file the file to open a Reader for |
97 | | - /// @param defaultCharset the default charset to use if no BOM header is present |
98 | | - /// @return a Reader for the given file |
99 | | - /// @throws IOException if an I/O error occurs opening the file |
100 | | - static Reader openReader(final Path file, final Charset defaultCharset) throws IOException { |
101 | | - final var bomHeader = detectCharset(file); |
102 | | - final var in = Files.newInputStream(file); |
103 | | - |
104 | | - // No BOM header found |
105 | | - if (bomHeader.isEmpty()) { |
106 | | - return new InputStreamReader(in, defaultCharset); |
107 | | - } |
108 | | - |
109 | | - // Return reader with skipped BOM header |
110 | | - final int bomLength = bomHeader.get().getLength(); |
111 | | - in.skipNBytes(bomLength); |
112 | | - return new InputStreamReader(in, bomHeader.get().getCharset()); |
113 | | - } |
114 | | - |
115 | 90 | } |
0 commit comments