Java UTF8 asUTF8(InputStream in)

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

Description

Create a reader that uses UTF-8 encoding

License

Open Source License

Declaration

static public Reader asUTF8(InputStream in) 

Method Source Code

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

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import java.io.Reader;

import java.io.Writer;

import java.nio.charset.Charset;

public class Main {
    static Charset utf8 = null;

    /** Create a reader that uses UTF-8 encoding */
    static public Reader asUTF8(InputStream in) {
        return new InputStreamReader(in, utf8.newDecoder());
    }//from   ww  w.  ja v a 2  s .c om

    /** Create a writer that uses UTF-8 encoding */
    static public Writer asUTF8(OutputStream out) {
        return new OutputStreamWriter(out, utf8.newEncoder());
    }
}

Related

  1. addLineIds(String inFile, String outFile)
  2. appendToFile(String outputFile, String contents)
  3. asStringUTF8(byte[] bytes)
  4. asUTF16BEEncoded(String basicString)
  5. asUtf8(byte[] bytes)
  6. asUTF8bytes(String s)
  7. asUtf8ByteStream(final String string)
  8. asUTF8String(byte[] bytes)
  9. asUTFString(byte[] content)