com.softicar.platform.common.io.reader.ManagedReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.io.reader;
import com.softicar.platform.common.core.exceptions.SofticarIOException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Collection;
/**
* Default implementation of {@link IManagedReader}.
*
* @author Oliver Richers
*/
public class ManagedReader implements IManagedReader {
private final Reader reader;
public ManagedReader(String string) {
this(new StringReader(string));
}
public ManagedReader(Reader reader) {
this.reader = reader;
}
@Override
public int read(char[] buffer) {
try {
return reader.read(buffer);
} catch (IOException exception) {
throw new SofticarIOException(exception);
}
}
@Override
public Collection readLines() {
return BufferedReaders.readLines(new BufferedReader(reader));
}
}