org.topoweb.io
Class ByteBufferOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.ByteArrayOutputStream
|
+--org.topoweb.io.ByteBufferOutputStream
- public class ByteBufferOutputStream
- extends java.io.ByteArrayOutputStream
An in-memory java.io.OutputStream
that supports a
backing java.nio.ByteBuffer
.
Implementation Note
The contents of the ByteBuffer
returned by instances
of this class are not protected against further modifications (for
example, by invoking the reset
method). Similarly,
modifications to the returned ByteBuffer
imply modifications
to the contents of this instance.
It also goes without saying that the behavior of this class is
undefined under concurrent access.
- Author:
- Babak Farhang
Fields inherited from class java.io.ByteArrayOutputStream |
buf, count |
Method Summary |
java.nio.ByteBuffer |
toByteBuffer()
Returns a ByteBuffer instance backed by this
instance's internal buffer. |
Methods inherited from class java.io.ByteArrayOutputStream |
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo |
Methods inherited from class java.io.OutputStream |
flush, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ByteBufferOutputStream
public ByteBufferOutputStream()
- Creates an instance with the default capacity. The default
capacity is just that of the superclass.
ByteBufferOutputStream
public ByteBufferOutputStream(int size)
- Creates an instance with specified initial
size
.
- Parameters:
size
- the initial byte size of the internal
array buffer.
toByteBuffer
public java.nio.ByteBuffer toByteBuffer()
- Returns a
ByteBuffer
instance backed by this
instance's internal buffer.
- Returns:
- a
ByteBuffer
with the
byte contents of this instance - See Also:
- Implementation Note
Copyright (C) 2002 Babak Farhang
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.