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

com.javanut.pronghorn.pipe.util.MutableCharReader Maven / Gradle / Ivy

Go to download

Ring buffer based queuing utility for applications that require high performance and/or a small footprint. Well suited for embedded and stream based processing.

There is a newer version: 1.1.27
Show newest version
package com.javanut.pronghorn.pipe.util;

import java.io.IOException;
import java.io.Reader;

public class MutableCharReader extends Reader implements Appendable {

	private final StringBuilder buffer = new StringBuilder();

	@Override
	public Appendable append(CharSequence source) throws IOException {
		buffer.append(source);
		return this;
	}


	@Override
	public Appendable append(char source) throws IOException {
		buffer.append(source);
		return this;
	}


	@Override
	public Appendable append(CharSequence source, int start, int end) throws IOException {
		buffer.append(source, start, end);
		return this;
	}
	
	public void clear() {
		buffer.setLength(0);
	}
	
	
	@Override
	public void close() throws IOException {
		buffer.setLength(0);
	}

	@Override
	public int read(char[] target, int off, int len) throws IOException {

		int j = 0;
		int copyLen = Math.min(buffer.length(), len);
		for(int i=off; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy