com.netaporter.salad.metrics.io

ThreadUnsafeByteArrayOutputStream

class ThreadUnsafeByteArrayOutputStream 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 ThreadUnsafeByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

This is modified to remove the synchronized methods, as in most cases the ByteArrayOutputStream is once use, single threaded in most cases.

Since

JDK1.0

Linear Supertypes
OutputStream, Flushable, Closeable, AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ThreadUnsafeByteArrayOutputStream
  2. OutputStream
  3. Flushable
  4. Closeable
  5. AutoCloseable
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ThreadUnsafeByteArrayOutputStream()

  2. new ThreadUnsafeByteArrayOutputStream(initialBufferSize: Int)

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. var buf: Array[Byte]

  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def close(): Unit

    Closing a ThreadUnsafeByteArrayOutputStream has no effect.

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

    Definition Classes
    ThreadUnsafeByteArrayOutputStream → OutputStream → Closeable → AutoCloseable
  8. var count: Int

    The number of valid bytes in the buffer.

    The number of valid bytes in the buffer.

    Attributes
    protected
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def flush(): Unit

    Definition Classes
    OutputStream → Flushable
    Annotations
    @throws( classOf[java.io.IOException] )
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. val initialBufferSize: Int

  16. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  20. def reset: Unit

    Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded.

    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.

    See also

    java.io.ByteArrayInputStream#count

  21. def size: Int

    Returns the current size of the buffer.

    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

    java.io.ByteArrayOutputStream#count

  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  23. def toByteArray: Array[Byte]

    Creates a newly allocated byte array.

    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

    java.io.ByteArrayOutputStream#size()

  24. def toString(charsetName: String): String

    Converts the buffer's contents into a string by decoding the bytes using the specified java.nio.charset.Charset charsetName.

    Converts the buffer's contents into a string by decoding the bytes using the specified java.nio.charset.Charset charsetName. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array.

    This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required.

    charsetName

    the name of a supported { @linkplain java.nio.charset.Charset charset}

    returns

    String decoded from the buffer's contents.

    Since

    JDK1.1

    Exceptions thrown
    UnsupportedEncodingException

    If the named charset is not supported

  25. def toString(): String

    Converts the buffer's contents into a string decoding bytes using the platform's default character set.

    Converts the buffer's contents into a string decoding bytes using the platform's default character set. The length of the new String is a function of the character set, and hence may not be equal to the size of the buffer.

    This method always replaces malformed-input and unmappable-character sequences with the default replacement string for the platform's default character set. The plain java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required.

    returns

    String decoded from the buffer's contents.

    Definition Classes
    ThreadUnsafeByteArrayOutputStream → AnyRef → Any
    Since

    JDK1.1

  26. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. def write(b: Array[Byte], off: Int, len: Int): Unit

    Writes len bytes from the specified byte array starting at offset off to this byte array output stream.

    Writes len bytes from the specified byte array starting at offset off to this byte array output stream.

    b

    the data.

    off

    the start offset in the data.

    len

    the number of bytes to write.

    Definition Classes
    ThreadUnsafeByteArrayOutputStream → OutputStream
  30. def write(b: Int): Unit

    Writes the specified byte to this byte array output stream.

    Writes the specified byte to this byte array output stream.

    b

    the byte to be written.

    Definition Classes
    ThreadUnsafeByteArrayOutputStream → OutputStream
  31. def write(arg0: Array[Byte]): Unit

    Definition Classes
    OutputStream
    Annotations
    @throws( classOf[java.io.IOException] )
  32. def writeTo(out: OutputStream): Unit

    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).

    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).

    out

    the output stream to which to write the data.

    Exceptions thrown
    IOException

    if an I/O error occurs.

Deprecated Value Members

  1. def toString(hibyte: Int): String

    Creates a newly allocated string.

    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))
    

    hibyte

    the high byte of each resulting Unicode character.

    returns

    the current contents of the output stream, as a string.

    Annotations
    @Deprecated
    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.

    See also

    java.io.ByteArrayOutputStream#toString()

    java.io.ByteArrayOutputStream#toString(String)

    java.io.ByteArrayOutputStream#size()

Inherited from OutputStream

Inherited from Flushable

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped