![JAR search and dependency download from the Maven repository](/logo.png)
org.snapscript.common.command.InputStreamConsole Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.common.command;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class InputStreamConsole implements Console {
private final LineNumberReader parser;
private final List lines;
private final Reader reader;
public InputStreamConsole(InputStream source) {
this.lines = new CopyOnWriteArrayList();
this.reader = new InputStreamReader(source);
this.parser = new LineNumberReader(reader);
}
public List readAll() throws IOException {
while (true) {
String line = parser.readLine();
if (line != null) {
lines.add(line);
} else {
break;
}
}
return lines;
}
@Override
public String readLine() throws IOException {
return parser.readLine();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy