Here you can find the source of readLineSet(InputStream stream)
Parameter | Description |
---|---|
inputStream | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static Set<String> readLineSet(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// w w w . j av a 2s . 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.HashSet; import java.util.Set; public class Main { /** * read a set of string lines from input stream and close it * * @param inputStream * @return * @throws IOException */ public static Set<String> readLineSet(InputStream stream) throws IOException { Set<String> values = new HashSet<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(); } } }