Java Text File Read by Charset createInputStreamReader(File file, String charsetName)

Here you can find the source of createInputStreamReader(File file, String charsetName)

Description

create Input Stream Reader

License

Open Source License

Declaration

public static InputStreamReader createInputStreamReader(File file, String charsetName)
            throws FileNotFoundException, UnsupportedEncodingException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

public class Main {
    public static InputStreamReader createInputStreamReader(File file, String charsetName)
            throws FileNotFoundException, UnsupportedEncodingException {
        Charset charset = charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName);
        return createInputStreamReader(file, charset);
    }/*  w ww  .j a  v a  2  s .  c  om*/

    public static InputStreamReader createInputStreamReader(File file, Charset charset)
            throws FileNotFoundException, UnsupportedEncodingException {
        FileInputStream is = new FileInputStream(file);
        return new InputStreamReader(is, charset);
    }
}

Related

  1. asReader(InputStream input, Charset charset)
  2. convert(File file, Charset from, String toEncoding, ByteArrayOutputStream bytearray, boolean headersOn, int totalLinesToRead)
  3. copy(Reader input, OutputStream output, Charset encoding)
  4. createBOMStrippedReader(InputStream stream, String defaultCharset)
  5. createBufferedReaderWithGuessedCharset(File file)
  6. createReader(Path p, Charset cs)
  7. getDecoder(Charset charset, ThreadLocal> localDecoder)
  8. getFileContent(IFile file, String charset)
  9. getInputStreamReader(InputStream stream, Charset charset)