All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.io.reader.ManagedReader Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
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));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy