java.io

Class ByteArrayOutputStream

Implemented Interfaces:
Closeable, Flushable

public class ByteArrayOutputStream
extends OutputStream

This class implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString().

Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

Since:
JDK1.0

Field Summary

protected byte[]
buf
The buffer where data is stored.
protected int
count
The number of valid bytes in the buffer.

Constructor Summary

ByteArrayOutputStream()
Creates a new byte array output stream.
ByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Method Summary

@Deprecated
String toString(int hibyte)
Deprecated. This method does not properly convert bytes into characters.
void
close()
Closing a ByteArrayOutputStream has no effect.
void
reset()
Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded.
int
size()
Returns the current size of the buffer.
byte[]
toByteArray()
Creates a newly allocated byte array.
String
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
String
toString(String enc)
Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding.
void
write(b[] , int off, int len)
Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
void
write(int b)
Writes the specified byte to this byte array output stream.
void
writeTo(OutputStream out)
Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).

Methods inherited from class java.io.OutputStream

close, flush, write, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buf

protected byte[] buf
The buffer where data is stored.

count

protected int count
The number of valid bytes in the buffer.

Constructor Details

ByteArrayOutputStream

public ByteArrayOutputStream()
Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary.
Usages and Demos :

View More Examples of ByteArrayOutputStream()
   1:         {
   2:             ObjectOutputStream    oos    = new ObjectOutputStream(new ByteArrayOutputStream());
   3:             oos.writeObject(getScope().getPlatformAgent());
   4:             oos.close();
   5:             report.setSucceeded(true);

View Full Code Here
   1:   {
   2:     super(new ByteArrayOutputStream());
   3:     out_=(ByteArrayOutputStream)out;
   4:   }

View Full Code Here
   1:   {
   2:     super( new ByteArrayOutputStream() );
   3:     name= "string".getBytes();
   4:   }

View Full Code Here
   1:     public double run(Product product, Object object) throws Exception {
   2:         product.serialize(object, new ByteArrayOutputStream());
   3: 
   4:         ...
   5:         for (int i = 0; i < iterations; i++) {
   6:             product.serialize(object, new ByteArrayOutputStream());
   7:         }
   8:         long end = System.currentTimeMillis();

View Full Code Here
   1:         final TasteException te4 = new TasteException(te3.toString());
   2:         te4.printStackTrace(new PrintStream(new ByteArrayOutputStream()));
   3:         ...
   4:         te4.printStackTrace(new PrintWriter(new OutputStreamWriter(new ByteArrayOutputStream())));
   5:     }
   6: 
   7: }

View Full Code Here

ByteArrayOutputStream

public ByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
Parameters:
size - the initial size.
Throws:
IllegalArgumentException - if size is negative.
Usages and Demos :

View More Examples of ByteArrayOutputStream(int size)
   1:         String filename = getFileName(attachment);
   2:         ByteArrayOutputStream outputStream = new ByteArrayOutputStream((int) attachment.getSize());
   3: 
   4:         int bytesRead = 0;
   5:         byte[] buffer = new byte[8192];

View Full Code Here
   1:         String filename = getFileName(attachment);
   2:         ByteArrayOutputStream outputStream = new ByteArrayOutputStream((int) attachment.getSize());
   3: 
   4:         int bytesRead = 0;
   5:         byte[] buffer = new byte[8192];

View Full Code Here
   1:     ByteArrayOutputStream out = 
   2:       new ByteArrayOutputStream((int) (bytes.length * 1.37));
   3:     Base64Encoder encodedOut = new Base64Encoder(out);
   4:     
   5:     try {

View Full Code Here
   1:     ByteArrayOutputStream out = 
   2:       new ByteArrayOutputStream((int) (bytes.length * 0.67));
   3: 
   4:     try {
   5:       int bytesRead;

View Full Code Here
   1:     ByteArrayOutputStream out =
   2:       new ByteArrayOutputStream((int) (base64.length() / 0.666));
   3:     byte[] buf = new byte[1024];
   4:     int len;
   5:     while ((len = in.read(buf)) != -1)

View Full Code Here

Method Details

String toString

public @Deprecated String toString(int hibyte)

Deprecated. This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the toString(String enc) method, which takes an encoding-name argument, or the toString() method, which uses the platform's default character encoding.

Creates a newly allocated string. Its size is the current size of the output stream and the valid contents of the buffer have been copied into it. Each character c in the resulting string is constructed from the corresponding element b in the byte array such that:
     c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))
 
Parameters:
hibyte - the high byte of each resulting Unicode character.
Returns:
the current contents of the output stream, as a string.

close

public void close()
            throws IOException
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

Specified by:
close in interface Closeable
Overrides:
close in interface OutputStream
Usages and Demos :

View More Examples of close()
   1: import java.io.BufferedInputStream;
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:         BufferedInputStream bis = new BufferedInputStream(is);
   6:         ByteArrayOutputStream bos = new ByteArrayOutputStream();
   7:         byte[] buffer = new byte[bufferSize];
   8:         ...
   9:         String contents = bos.toString();
  10:         bis.close();
  11:         ...
  12:         bos.close();

View Full Code Here
   1:   {
   2:     ByteArrayOutputStream baos = new ByteArrayOutputStream();
   3:     new ObjectOutputStream( baos ).writeObject( o );
   4:         ...
   5:     baos.close();
   6:     
   7:         ...
   8:     Object p = new ObjectInputStream(bais).readObject();
   9:     bais.close();
  10:     

View Full Code Here
   1:         
   2:         ByteArrayOutputStream bOut = new ByteArrayOutputStream();
   3:         
   4:         ...
   5:         
   6:         bOut.close();
   7:         
   8:         InputStream in = new ByteArrayInputStream(bOut.toByteArray());
   9:         

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:         try {
   6:             ByteArrayOutputStream out = new ByteArrayOutputStream();
   7:             InputStream in = url.openStream();
   8:         ...
   9:             }
  10:             in.close();
  11:         ...
  12:             out.close();

View Full Code Here
   1:         
   2:         ByteArrayOutputStream bOut = new ByteArrayOutputStream();
   3:         
   4:         ...
   5:         
   6:         bOut.close();
   7:         
   8:         InputStream in = new ByteArrayInputStream(bOut.toByteArray());
   9:         

View Full Code Here

reset

public void reset()
Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded. The output stream can be used again, reusing the already allocated buffer space.
Usages and Demos :

View More Examples of reset()
   1:   private boolean               close_;
   2:   private ByteArrayOutputStream out_;
   3: 
   4:         ...
   5:   {
   6:     super(new ByteArrayOutputStream());
   7:         ...
   8:     out_=(ByteArrayOutputStream)out;
   9:   }
  10:         ...
  11:     flush();
  12:     out_.reset();

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5: 
   6:     ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   7: 
   8:         ...
   9:     {
  10:         outputStream.reset();
  11:     }

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     private ZipOutputStream zout;
   6:     private ByteArrayOutputStream bout;
   7:     private DataOutputStream dout;
   8:         ...
   9:         this.zout = zout;
  10:         bout = new ByteArrayOutputStream();
  11:         dout = new DataOutputStream(bout);
  12:         ...
  13:         try {
  14:             bout.reset();

View Full Code Here
   1:         headers = new Hashtable();
   2:         ByteArrayOutputStream bout = new ByteArrayOutputStream();
   3:         int ch = read();
   4:         ...
   5:                             headers.put(key.toLowerCase(), value);
   6:                             bout.reset();
   7:                             break;
   8:                         }
   9:                     }

View Full Code Here
   1: 
   2:     private ByteArrayOutputStream buf = null;
   3:     private int id;
   4:         ...
   5:     {
   6:         buf = new ByteArrayOutputStream();
   7:         id = 0;
   8:         ...
   9:     {
  10:         buf = new ByteArrayOutputStream();
  11:         id = val1;
  12:         ...
  13:     {
  14:         buf.reset();

View Full Code Here

size

public int size()
Returns the current size of the buffer.
Returns:
the value of the count field, which is the number of valid bytes in this output stream.
See Also:
count
Usages and Demos :

View More Examples of size()
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5:     public double run(Product product, Object object) throws Exception {
   6:         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
   7:         product.serialize(object, buffer);
   8:         ...
   9:         return buffer.size();
  10:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:         ByteArrayOutputStream myBAOS = new ByteArrayOutputStream();
   7:         ObjectOutputStream myOOS = new ObjectOutputStream(myBAOS);
   8:         ...
   9: 
  10:         return myBAOS.size();
  11:     }

View Full Code Here
   1:   private boolean               close_;
   2:   private ByteArrayOutputStream out_;
   3: 
   4:         ...
   5:   {
   6:     super(new ByteArrayOutputStream());
   7:         ...
   8:     out_=(ByteArrayOutputStream)out;
   9:   }
  10:         ...
  11:     flush();
  12:     return out_.size();

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     private ByteArrayOutputStream buf;
   7:     private PrintStream ps;
   8:         ...
   9:     public ByteArrayStringCollector() {
  10:         buf = new ByteArrayOutputStream();
  11:         ps = new PrintStream(buf);
  12:         ...
  13:         ps.flush();
  14:         return buf.size();

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5: 
   6:     private ByteArrayOutputStream buffer;
   7: 
   8:         ...
   9:     {
  10:         buffer = new ByteArrayOutputStream();
  11:     }
  12:         ...
  13:     {
  14:         return buffer.size();

View Full Code Here

toByteArray

public byte[] toByteArray()
Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it.
Returns:
the current contents of this output stream, as a byte array.
See Also:
size()
Usages and Demos :

View More Examples of toByteArray()
   1:     System.out.println("Pred:\n" + sc);
   2:     ByteArrayOutputStream buf = 
   3:         ...
   4:       new ByteArrayOutputStream();
   5:     ObjectOutputStream vystup =
   6:         ...
   7:         new ByteArrayInputStream(
   8:           buf.toByteArray()));
   9:     SerialCtl sc2 = (SerialCtl)vstup.readObject();

View Full Code Here
   1:     long t1 = System.currentTimeMillis();
   2:     ByteArrayOutputStream vyrVystup = 
   3:         ...
   4:       new ByteArrayOutputStream();
   5:     ObjectOutputStream vystup =
   6:         ...
   7:         new ByteArrayInputStream(
   8:           vyrVystup.toByteArray()));
   9:     Vec2[] c = new Vec2[VELIKOST];

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5: public class ProtocolLayerSharedBuffer extends ProtocolLayer {
   6:     private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
   7: 
   8:         ...
   9:         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
  10:                 byteArrayOutputStream.toByteArray());
  11:         byteArrayOutputStream.reset();
  12:         ...
  13:     public byte[] toByteArray() {
  14:         return byteArrayOutputStream.toByteArray();

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.InputStream;
   4:         ...
   5:   
   6:   protected ByteArrayOutputStream thisStream;
   7:   protected Transformer transformer;
   8:         ...
   9:   {
  10:     thisStream = new ByteArrayOutputStream();
  11:     try {
  12:         ...
  13:       transformer.transform( new StreamSource( new ByteArrayInputStream( 
  14:           thisStream.toByteArray() ) ), result  );

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.ObjectInput;
   4:         ...
   5:         try {
   6:             ByteArrayOutputStream buffer = new ByteArrayOutputStream();
   7:             ObjectOutput out = new ObjectOutputStream(buffer);
   8:         ...
   9:             ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
  10:                 buffer.toByteArray())
  11:             );

View Full Code Here

toString

public String toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
Overrides:
toString in interface Object
Returns:
String translated from the buffer's contents.
Since:
JDK1.1
Usages and Demos :

View More Examples of toString()
   1: import java.io.ByteArrayOutputStream;
   2: 
   3:         ...
   4:   
   5:     ByteArrayOutputStream out = new ByteArrayOutputStream(s.length());
   6:   
   7:         ...
   8: 
   9:     return out.toString();
  10:    

View Full Code Here
   1: import java.io.PrintStream;
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5:    public static String toString(final Throwable t) {
   6:       ByteArrayOutputStream output = new ByteArrayOutputStream();
   7:       PrintStream stream = new PrintStream(output);
   8:         ...
   9: 
  10:       return output.toString();
  11:    }

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     private ByteArrayOutputStream buf;
   7:     private PrintStream ps;
   8:         ...
   9:     public ByteArrayStringCollector() {
  10:         buf = new ByteArrayOutputStream();
  11:         ps = new PrintStream(buf);
  12:         ...
  13:     public String toString() {
  14:         return buf.toString();

View Full Code Here
   1:                     Context c = (Context)context.clone();
   2:                     ByteArrayOutputStream bout = new ByteArrayOutputStream();
   3:                     c.setOutputStream(bout);
   4:         ...
   5:                     }
   6:                     return bout.toString();
   7:                 }
   8:             };
   9:     }

View Full Code Here
   1: import java.io.BufferedReader;
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     ByteArrayOutputStream output;
   7: 
   8:         ...
   9:     public String toString() {
  10:         return output.toString();
  11:     }
  12:         ...
  13:             this.join();
  14:             return output.toString();

View Full Code Here

toString

public String toString(String enc)
            throws UnsupportedEncodingException
Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding.
Parameters:
enc - a character-encoding name.
Returns:
String translated from the buffer's contents.
Throws:
UnsupportedEncodingException - If the named encoding is not supported.
Since:
JDK1.1
Usages and Demos :

View More Examples of toString(String enc)
   1: import java.io.OutputStream;
   2: import java.io.ByteArrayOutputStream;
   3: import org.outerj.daisy.xmlutil.SaxBuffer;
   4:         ...
   5:     public byte[] cleanToByteArray(String somethingWhichLooksLikeHtml) throws Exception {
   6:         ByteArrayOutputStream os = new ByteArrayOutputStream(10000);
   7:         clean(somethingWhichLooksLikeHtml, os);
   8:         ...
   9:         clean(somethingWhichLooksLikeHtml, os);
  10:         return os.toString("UTF-8");
  11:     }

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:     private static String serializeDocument(Document doc) throws IOException, TransformerException {
   6:         ByteArrayOutputStream s= new ByteArrayOutputStream();
   7:         
   8:         TransformerFactory factory= TransformerFactory.newInstance();
   9:         Transformer transformer= factory.newTransformer();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ByteArrayOutputStream;
   3: import org.apache.tools.ant.taskdefs.PumpStreamHandler;
   4:         ...
   5:         super(new RedirectingOutputStream(parser),
   6:             new ByteArrayOutputStream());
   7:     }
   8:         ...
   9:         try {
  10:             final ByteArrayOutputStream error 
  11:                 = (ByteArrayOutputStream) getErr();
  12:         ...
  13: 
  14:             return error.toString("ASCII");

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.FileInputStream;
   4:         ...
   5:         MessageDigest md;
   6:         ByteArrayOutputStream bos;
   7: 
   8:         ...
   9:             byte[] digest = md.digest(pass.getBytes("iso-8859-1"));
  10:             bos = new ByteArrayOutputStream();
  11:             OutputStream encodedStream = MimeUtility.encode(bos, "base64");
  12:         ...
  13:             encodedStream.write(digest);
  14:             return bos.toString("iso-8859-1");

View Full Code Here
   1:         int stoppedAt = 0;
   2:         ByteArrayOutputStream buf = new ByteArrayOutputStream();
   3:         char c;
   4:         ...
   5:             buf.write(bytes, 0, bytes.length);
   6:             return buf.toString("US-ASCII");
   7:             return ""; 
   8:         }
   9:     }

View Full Code Here

write

public void write(b[] ,
                  int off,
                  int len)
Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
Overrides:
write in interface OutputStream
Parameters:
off - the start offset in the data.
len - the number of bytes to write.
Usages and Demos :

View More Examples of write(b[] ,int off,int len)
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5:     public String toString() {
   6:     ByteArrayOutputStream out = new ByteArrayOutputStream();
   7:     
   8:         ...
   9:         out.write(NYBBLE[(repn[i] >> 4) & 0x0F], 0, 4);
  10:         out.write(NYBBLE[repn[i] & 0x0F], 0, 4);
  11:        

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:     
   6:     ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
   7:     PngChunk chunk;
   8:         ...
   9:     byte[] temp = {byte1, byte2};
  10:     baos.write(temp, 0, 2);
  11: 
  12:         ...
  13:     byte[] temp = {byte1, byte2, byte3, byte4};
  14:     baos.write(temp, 0, 4);

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.security.interfaces.RSAKey;
   4:         ...
   5: 
   6:   private ByteArrayOutputStream baos = new ByteArrayOutputStream();
   7: 
   8:         ...
   9:     baos.write(0x02);
  10:     baos.write(PS, 0, PS.length);
  11:     baos.write(0x00);
  12:         ...
  13:     baos.write(M, 0, M.length);

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5:   {
   6:     final ByteArrayOutputStream baos = new ByteArrayOutputStream();
   7:         ...
   8:     baos.write(prefix, 0, prefix.length);
   9:         ...
  10:     baos.write(mHash, 0, mHash.length);

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:     {
   6:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
   7: 
   8:         ...
   9:                     if (b>0)
  10:                         baos.write(_byteBoundary,0,b);
  11:                     b=-1;
  12:         ...
  13:             {
  14:                 baos.write(_byteBoundary,0,b);

View Full Code Here

write

public void write(int b)
Writes the specified byte to this byte array output stream.
Overrides:
write in interface OutputStream
Parameters:
b - the byte to be written.
Usages and Demos :

View More Examples of write(int b)
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: 
   4:         ...
   5: 
   6:   private ByteArrayOutputStream out = new ByteArrayOutputStream();
   7: 
   8:         ...
   9:           out.write(btoWrite, i + 4 + 1, (int) size + 3);
  10:           out.write(" ".getBytes());
  11:         }

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:     {
   6:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
   7:         int add = 16;
   8:         ...
   9:                 + "\r\n";
  10:             baos.write(header.getBytes("US-ASCII"));
  11:             for (int j = 0;  j < i;  j++) {
  12:         ...
  13:                 baos.write((byte) j);

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:         final int NUM_ITEMS = 512;
   6:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
   7:         for (int i = 0;  i < NUM_ITEMS;  i++) {
   8:         ...
   9:                 + "\r\n";
  10:             baos.write(header.getBytes("US-ASCII"));
  11:             for (int j = 0;  j < 16384+i;  j++) {
  12:         ...
  13:                 baos.write((byte) j);

View Full Code Here
   1: import java.awt.Point;
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:     public byte[] write() {
   6:         ByteArrayOutputStream result = new ByteArrayOutputStream();
   7:         try {
   8:         ...
   9:             result.write(OPEN_GROUP);
  10:         ...
  11:             result.write("\\sp".getBytes());

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.File;
   4:         ...
   5:         path = getDisplayPath(path);
   6:         ByteArrayOutputStream bos = new ByteArrayOutputStream();
   7:         diff = new TreeMap(diff);
   8:         ...
   9:         try {
  10:             bos.write(EOL);
  11:             bos.write(("Property changes on: " + path.replace('/', File.separatorChar)).getBytes(getEncoding()));
  12:         ...
  13:             bos.write(EOL);

View Full Code Here

writeTo

public void writeTo(OutputStream out)
            throws IOException
Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).
Parameters:
out - the output stream to which to write the data.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeTo(OutputStream out)
   1:     private Writer writer;
   2:     private ByteArrayOutputStream bout;
   3:     private boolean buffering;
   4:         ...
   5:             if (buffering){
   6:                 this.bout = new ByteArrayOutputStream();
   7:                 w = new BufferedWriter(new OutputStreamWriter(this.bout, response.getCharacterEncoding()));
   8:         ...
   9:                 OutputStream out = response.getOutputStream();
  10:                 bout.writeTo(out);
  11:                 bout.reset();

View Full Code Here
   1: 
   2:       ByteArrayOutputStream byteStream =
   3:         ...
   4:         new ByteArrayOutputStream();
   5:       GZIPOutputStream zipOut =
   6:         ...
   7:       OutputStream realOut = res.getOutputStream();
   8:       byteStream.writeTo(realOut);
   9:     }

View Full Code Here
   1: 
   2:     ByteArrayOutputStream headerBAOS = new ByteArrayOutputStream(nheaderbytes);
   3:     DataOutputStream headerStream = new DataOutputStream(headerBAOS);
   4:         ...
   5:     ByteArrayOutputStream pageBAOS = new ByteArrayOutputStream(npagebytes);
   6:     DataOutputStream pageStream = new DataOutputStream(pageBAOS);
   7:         ...
   8:         headerStream.flush();
   9:         headerBAOS.writeTo(os);
  10:         pageStream.flush();
  11:         ...
  12:         pageBAOS.writeTo(os);

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.DataInputStream;
   4:         ...
   5:     {
   6:         ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
   7:         DataOutputStream outputStream = new DataOutputStream(baOutputStream);
   8:         ...
   9:         httpServletResponse.setContentLength(baOutputStream.size());
  10:         baOutputStream.writeTo(httpServletResponse.getOutputStream());
  11:         outputStream.flush();

View Full Code Here
   1: 
   2: import java.io.ByteArrayOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:     
   6:     private final ByteArrayOutputStream memOut;
   7: 
   8:         ...
   9:         out = anOut;
  10:         memOut = new ByteArrayOutputStream(2048);
  11:         streamOutputStream = new StreamOutputStream(memOut, aManager, aResolver);
  12:         ...
  13:             try {
  14:                 memOut.writeTo(out);

View Full Code Here