Java BufferedReader Create getReader(InputStream input)

Here you can find the source of getReader(InputStream input)

Description

get Reader

License

Open Source License

Declaration

public static String getReader(InputStream input) 

Method Source Code


//package com.java2s;
/* Copyright (c) 2011 by crossmobile.org
 *
 * CrossMobile is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.
 *
 * CrossMobile is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CrossMobile; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *///www. ja v a 2  s.c o m

import java.io.BufferedReader;

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

public class Main {
    private final static String NL = System.getProperty("line.separator");

    public static String getReader(InputStream input) {
        BufferedReader in = null;
        StringBuilder out = new StringBuilder();
        try {
            in = new BufferedReader(new InputStreamReader(input, "UTF-8"));
            String line;
            while ((line = in.readLine()) != null) {
                out.append(line);
                out.append(NL);
            }
            return out.toString();
        } catch (IOException ex) {
            System.err.println(ex.toString());
            return null;
        } finally {
            if (in != null)
                try {
                    in.close();
                } catch (IOException ex) {
                }
        }
    }
}

Related

  1. getReader(final InputStream is, final String enc)
  2. getReader(final Object aReference, final String aResourceName)
  3. getReader(final String fileName)
  4. getReader(final String fileName)
  5. getReader(InputStream in)
  6. getReader(InputStream is)
  7. getReader(InputStream is)
  8. getReader(String fileDir, String fileName, String encoding)
  9. getReader(String filename)