Java InputStream Read Line readLines(final InputStream is)

Here you can find the source of readLines(final InputStream is)

Description

read Lines

License

Open Source License

Declaration

public static List<String> readLines(final InputStream is) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 * This file is part of the Prolog Development Tools (ProDT)
 *
 * Author: Claudio Cancinos//  ww w . j ava 2 s .  c  om
 * WWW: https://sourceforge.net/projects/prodevtools
 * Copyright (C): 2008, Claudio Cancinos
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program 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 Lesser General Public
 * License along with this program; If not, see <http://www.gnu.org/licenses/>
 ****************************************************************************/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> readLines(final InputStream is) {
        try {
            final List<String> lines = new ArrayList<String>();
            final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = reader.readLine()) != null) {
                lines.add(line);
            }
            return lines;
        } catch (final IOException e) {
            throw new RuntimeException("Error while reading input stream lines", e);
        } finally {
            try {
                is.close();
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. readLines(ByteArrayInputStream outputSource)
  2. readLines(final InputStream in)
  3. readLines(final InputStream input, final String encoding)
  4. readLines(final InputStream inputStream)
  5. readLines(final InputStream inputStream)
  6. readlines(final InputStream stream)
  7. readLines(InputStream in)
  8. readLines(InputStream in)
  9. readLines(InputStream in)