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

org.codehaus.plexus.util.StringOutputStream Maven / Gradle / Ivy

Go to download

A collection of various utility classes to ease working with strings, files, command lines, XML and more.

There is a newer version: 4.0.2
Show newest version
package org.codehaus.plexus.util;

import java.io.IOException;
import java.io.OutputStream;

/**
 * Wraps a String as an OutputStream.
 *
 * @author Emmanuel Venisse
 * @version $Id: StringOutputStream.java 5958 2007-02-28 10:29:55Z olamy $
 */
public class StringOutputStream
    extends OutputStream
{
    private StringBuffer buf = new StringBuffer();

    public void write( byte[] b ) throws IOException
    {
        buf.append( new String( b ) );
    }

    public void write( byte[] b, int off, int len ) throws IOException
    {
        buf.append( new String( b, off, len ) );
    }

    public void write( int b ) throws IOException
    {
        byte[] bytes = new byte[1];
        bytes[0] = (byte)b;
        buf.append( new String( bytes ) );
    }

    public String toString()
    {
        return buf.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy