/** * Gets a <code>BufferedReader</code> (indeed a <code>LineNumberReader</code>) from the <code>File</code> * specified in the constructor of <code>CharsetToolkit</code> using the charset discovered or the default * charset if an 8-bit <code>Charset</code> is encountered. * * @return a <code>BufferedReader</code> * @throws FileNotFoundException if the file is not found. */ public BufferedReader getReader() throws FileNotFoundException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(file), getCharset())); if (hasUTF8Bom() || hasUTF16LEBom() || hasUTF16BEBom()) { try { reader.read(); } catch (IOException e) { // should never happen, as a file with no content // but with a BOM has at least one char } } return reader; }
if (hasUTF8Bom()) return Charset.forName("UTF-8"); if (hasUTF16LEBom())
/** * Gets a <code>BufferedReader</code> (indeed a <code>LineNumberReader</code>) from the <code>File</code> * specified in the constructor of <code>CharsetToolkit</code> using the charset discovered by the * method <code>guessEncoding()</code>. * * @return a <code>BufferedReader</code> * @throws FileNotFoundException if the file is not found. */ public BufferedReader getReader() throws FileNotFoundException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(file), getCharset())); if (hasUTF8Bom() || hasUTF16LEBom() || hasUTF16BEBom()) { try { reader.read(); } catch (IOException e) { // should never happen, as a file with no content // but with a BOM has at least one char } } return reader; }
/** * Gets a <code>BufferedReader</code> (indeed a <code>LineNumberReader</code>) from the <code>File</code> * specified in the constructor of <code>CharsetToolkit</code> using the charset discovered or the default * charset if an 8-bit <code>Charset</code> is encountered. * * @return a <code>BufferedReader</code> * @throws FileNotFoundException if the file is not found. */ public BufferedReader getReader() throws FileNotFoundException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(file), getCharset())); if (hasUTF8Bom() || hasUTF16LEBom() || hasUTF16BEBom()) { try { reader.read(); } catch (IOException e) { // should never happen, as a file with no content // but with a BOM has at least one char } } return reader; }
/** * Gets a <code>BufferedReader</code> (indeed a <code>LineNumberReader</code>) from the <code>File</code> * specified in the constructor of <code>CharsetToolkit</code> using the charset discovered by the * method <code>guessEncoding()</code>. * * @return a <code>BufferedReader</code> * @throws FileNotFoundException if the file is not found. */ public BufferedReader getReader() throws FileNotFoundException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(file), getCharset())); if (hasUTF8Bom() || hasUTF16LEBom() || hasUTF16BEBom()) { try { reader.read(); } catch (IOException e) { // should never happen, as a file with no content // but with a BOM has at least one char } } return reader; }
/** * Gets a <code>BufferedReader</code> (indeed a <code>LineNumberReader</code>) from the <code>File</code> * specified in the constructor of <code>CharsetToolkit</code> using the charset discovered by the * method <code>guessEncoding()</code>. * * @return a <code>BufferedReader</code> * @throws FileNotFoundException if the file is not found. */ public BufferedReader getReader() throws FileNotFoundException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(file), getCharset())); if (hasUTF8Bom() || hasUTF16LEBom() || hasUTF16BEBom()) { try { reader.read(); } catch (IOException e) { // should never happen, as a file with no content // but with a BOM has at least one char } } return reader; }
if (hasUTF8Bom()) return Charset.forName("UTF-8"); if (hasUTF16LEBom())
if (hasUTF8Bom()) return Charset.forName("UTF-8"); if (hasUTF16LEBom())
if (hasUTF8Bom()) return Charset.forName("UTF-8"); if (hasUTF16LEBom())
if (hasUTF8Bom()) return Charset.forName("UTF-8"); if (hasUTF16LEBom())