Skip navigation links

Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10696-05


oracle.security.crypto.util
Class FixedByteArrayOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by oracle.security.crypto.util.FixedByteArrayOutputStream

All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class FixedByteArrayOutputStream
extends java.io.OutputStream

A fixed-size, unsynchronized ByteArrayOutptStream, that provides access to the internal buffer for efficiency.


Field Summary
protected  byte[] buf
          The buffer to contains the bytes written to this stream.
protected  int count
          The number of bytes written to this stream.

 

Constructor Summary
FixedByteArrayOutputStream(byte[] buf)
          Creates a FixedByteArrayOutputStream using the given buffer.
FixedByteArrayOutputStream(int size)
          Creates a FixedByteArrayOutputStream with a newly allocated buffer of the given size.

 

Method Summary
 int bufSize()
          Returns the capacity of the internal buffer.
 void close()
          Closes this output stream.
 byte[] getBytes()
          Returns a reference to the full internal buffer.
 void reset()
          Resets the count of bytes written to this stream to zero.
 int size()
          Returns the number of bytes written to this stream.
 byte[] toByteArray()
          Returns a newly allocated byte array of size equal to the number of valid bytes written to this stream.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           

 

Methods inherited from class java.io.OutputStream
flush

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

buf

protected byte[] buf
The buffer to contains the bytes written to this stream.

count

protected int count
The number of bytes written to this stream.

Constructor Detail

FixedByteArrayOutputStream

public FixedByteArrayOutputStream(int size)
Creates a FixedByteArrayOutputStream with a newly allocated buffer of the given size.

FixedByteArrayOutputStream

public FixedByteArrayOutputStream(byte[] buf)
Creates a FixedByteArrayOutputStream using the given buffer. The initial contents of buf, if any, will be ignored.

Method Detail

close

public void close()
           throws java.io.IOException
Closes this output stream. Calls to write methods after close will cause an exception to be thrown.
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

reset

public void reset()
Resets the count of bytes written to this stream to zero.

size

public int size()
Returns the number of bytes written to this stream.

bufSize

public int bufSize()
Returns the capacity of the internal buffer.

toByteArray

public byte[] toByteArray()
Returns a newly allocated byte array of size equal to the number of valid bytes written to this stream.

getBytes

public byte[] getBytes()
Returns a reference to the full internal buffer. If the buffer is not full, an IllegalStateException is thrown.

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

Skip navigation links

Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10696-05


Copyright © 2005, 2013, Oracle. All rights reserved.