Byte arrayoutputstream

233 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
233
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Byte arrayoutputstream

  1. 1. Class ByteArrayOutputStream ByteArrayOutputStream
  2. 2. ByteArrayOutputStream • 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(). ByteArrayOutputStream
  3. 3. syntax java.io.ByteArrayOutputStream public class ByteArrayOutputStream extends OutputStream ByteArrayOutputStream
  4. 4. Constructor ByteArrayOutputStream() • Creates a new byte array output stream. ByteArrayOutputStream
  5. 5. 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. ByteArrayOutputStream
  6. 6. toByteArray() • public byte[] toByteArray() ByteArrayOutputStream
  7. 7. 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. • public void reset() ByteArrayOutputStream
  8. 8. Close() • Closes this output stream and releases any system resources associated with this stream. A closed stream cannot perform output operations and cannot be reopened. • public void close() throws IOException ByteArrayOutputStream

×