Java UTF8 getUTF8Reader(InputStream f)

Here you can find the source of getUTF8Reader(InputStream f)

Description

get UTF Reader

License

Open Source License

Declaration

private static Reader getUTF8Reader(InputStream f) throws IOException 

Method Source Code

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

import java.io.BufferedInputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

public class Main {
    private static Reader getUTF8Reader(InputStream f) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(f);
        assert bis.markSupported();
        bis.mark(3);// w ww  . ja  v  a2s  .  c  om
        boolean reset = true;
        byte[] t = new byte[3];
        bis.read(t);
        if (t[0] == ((byte) 0xef) && t[1] == ((byte) 0xbb)
                && t[2] == ((byte) 0xbf)) {
            reset = false;
        }
        if (reset) {
            bis.reset();
        }
        return new InputStreamReader(bis, "UTF-8");
    }
}

Related

  1. GetUtf8Bytes(String str, boolean replace)
  2. getUTF8Bytes(String string)
  3. getUTF8BytesFromString(String str)
  4. getUtf8Decoder()
  5. getUtf8OrDefault()
  6. getUtf8String(URL url)
  7. getUTF8SuportOutput()
  8. getUTF8Writer(String path)
  9. hasLeadingWhitespace(File inputFile)