Java UTF8 File Read utf8Reader(InputStream in)

Here you can find the source of utf8Reader(InputStream in)

Description

Creates a reader whose character encoding is set to "UTF-8".

License

Open Source License

Parameter

Parameter Description
in the input stream to read from

Return

the reader

Declaration

public static Reader utf8Reader(InputStream in) 

Method Source Code

//package com.java2s;

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

import java.io.InputStream;
import java.io.InputStreamReader;

import java.io.Reader;

import java.nio.charset.Charset;

public class Main {
    private static final Charset UTF8 = Charset.forName("UTF-8");

    /**/*from  w w  w .j  a  v a  2 s  . co  m*/
     * Creates a reader whose character encoding is set to "UTF-8".
     * @param in the input stream to read from
     * @return the reader
     */
    public static Reader utf8Reader(InputStream in) {
        return new InputStreamReader(in, UTF8);
    }

    /**
     * Creates a reader whose character encoding is set to "UTF-8".
     * @param file the file to read from
     * @return the reader
     * @throws FileNotFoundException if the file can't be read
     */
    public static Reader utf8Reader(File file) throws FileNotFoundException {
        return utf8Reader(new FileInputStream(file));
    }
}

Related

  1. readStringUTF16LE(byte[] var0, int var1, int var2)
  2. readTextFile(File inputFile)
  3. readUTF8(DataInput buf)
  4. readUtf8String(DataInputStream in)
  5. readUTFByteArrayFromDataInput(final DataInput in)