Here you can find the source of getReader(String path, Charset encoding)
Parameter | Description |
---|---|
path | the location of the file to be read |
encoding | the character set used for reading the file |
public static BufferedReader getReader(String path, Charset encoding) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; public class Main { /**//from w w w . j av a 2 s . c o m * Returns a reader that uses the UTF8 encoding. * * @param path the location of the file to be read * @return a reader that uses the UTF8 encoding */ public static BufferedReader getReader(String path) throws FileNotFoundException { return getReader(path, StandardCharsets.UTF_8); } /** * Returns a reader that uses the given encoding. * * @param path the location of the file to be read * @param encoding the character set used for reading the file * @return a reader that uses the given encoding */ public static BufferedReader getReader(String path, Charset encoding) throws FileNotFoundException { return new BufferedReader(new InputStreamReader(new FileInputStream(new File(path)), encoding)); } }