Java UTF InputStreamReader Create newUtf8StreamReader(InputStream is)

Here you can find the source of newUtf8StreamReader(InputStream is)

Description

new Utf Stream Reader

License

Open Source License

Declaration

public static Reader newUtf8StreamReader(InputStream is) 

Method Source Code

//package com.java2s;
/*/*from w  w w .  j  a  va 2s  . c o m*/
 * Copyright (c) 2003-2009 Mark Logic Corporation. All rights reserved.
 *
 * This program and the accompanying materials are made available 
 * under the terms of the Eclipse Public License v1.0 which 
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Mark Logic, Inc.
 */

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

import java.io.UnsupportedEncodingException;

public class Main {
    public static Reader newUtf8StreamReader(InputStream is) {
        try {
            return (new InputStreamReader(is, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            // This is extrememly unlikely to happen, UTF-8 is required on all compliant JVMs
            return (new InputStreamReader(is));
        }
    }
}