Here you can find the source of readLineList(InputStream stream)
Parameter | Description |
---|---|
inputStream | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static LinkedList<String> readLineList(InputStream stream) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2012 Nikita Zhiltsov. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html/*from w w w .j a v a 2 s. co m*/ * * Contributors: * Nikita Zhiltsov - initial API and implementation * Azat Khasanshin - implementation ******************************************************************************/ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.util.LinkedList; public class Main { /** * read an ordered list of string lines from input stream and close it * * @param inputStream * @return * @throws IOException */ public static LinkedList<String> readLineList(InputStream stream) throws IOException { LinkedList<String> values = new LinkedList<String>(); try { LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(stream)); String line = null; while ((line = lineReader.readLine()) != null) { values.add(line); } return values; } finally { stream.close(); } } }