Java Text File Read by Charset getReader(InputStream in, String charsetName)

Here you can find the source of getReader(InputStream in, String charsetName)

Description

get Reader

License

Open Source License

Declaration

public static BufferedReader getReader(InputStream in, String charsetName) throws IOException 

Method Source Code


//package com.java2s;
import java.io.*;

import java.nio.charset.Charset;

public class Main {

    public static BufferedReader getReader(InputStream in, String charsetName) throws IOException {
        return getReader(in, Charset.forName(charsetName));
    }//  w w  w.j a  v a  2  s.  com

    public static BufferedReader getReader(InputStream in, Charset charset) throws IOException {
        if (null == in) {
            return null;
        }

        InputStreamReader reader = null;
        if (null == charset) {
            reader = new InputStreamReader(in);
        } else {
            reader = new InputStreamReader(in, charset);
        }

        return new BufferedReader(reader);
    }
}

Related

  1. createInputStreamReader(File file, String charsetName)
  2. createReader(Path p, Charset cs)
  3. getDecoder(Charset charset, ThreadLocal> localDecoder)
  4. getFileContent(IFile file, String charset)
  5. getInputStreamReader(InputStream stream, Charset charset)
  6. getReader(InputStream is, String charset)
  7. getReader(String fileName, Charset cs)
  8. getReader(String path, Charset encoding)
  9. inferCharset(byte[] bytes, int bytesRead, Charset clientCharset)