Your SlideShare is downloading. ×
Byte arrayinputstream.50
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Byte arrayinputstream.50

107
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
107
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. ByteArrayInputStream class http://improvejava.blogspot.in/ 1
  • 2. ObjectivesOn completion of this period, you would be able to learn • Other I/O stream classes • ByteArrayInputStream • ByteArrayOutputStream • BufferedInputStream • BufferedOutputStream http://improvejava.blogspot.in/ 2
  • 3. RecapIn the last class, you have studied about the types Stream Class• Byte Streams are two types 1. InputStream class 2. OutputStream class• FileInputStream and FileOutputStream are the subclasses of byte stream• Let us explore some more stream classes http://improvejava.blogspot.in/ 3
  • 4. ByteArrayInputStream class• Data stored in memory is handled by ByteArrayInputStream• This class is used to read bytes from a memory• Objects of this class are used to create input stream with memory buffers as data source• Constructors • ByteArrayInputStream(byte array[ ]) • ByteArrayInputStream(byte array[ ], int start, int numBytes) http://improvejava.blogspot.in/ 4
  • 5. ByteArrayOutputStream class• Data stored in memory is handled by ByteArrayOutputStream• This class is used to write bytes into memory• Objects of this class are used to create output stream with memory buffers as data sink• Constructors • ByteArrayOutputStream( ) • ByteArrayOutputStream(int numBytes) • In the first form, a buffer of 32 bytes is created. • In the second, a buffer is created with a size equal to that specified by numBytes http://improvejava.blogspot.in/ 5
  • 6. Filtered Byte Stream class• Byte streams access the data in byte form• Raw bytes can not be used for any useful purpose• For converting bytes to useful forms such as char, string, int, etc filtered streams are used• Streams that can take other stream as arguments are called filtered streams• FilterInputStream • BufferedInputStream is a subclass of it• FilterOutputStream • BufferedOutputStream is a subclass of it In many practical situations only filtered streams are useful http://improvejava.blogspot.in/ 6
  • 7. BufferedInputStream class• This is a subclass of FilterInpuStream• This class is used to increase the efficiency of reading bytes from an input stream• Fetching a byte and sending it to the destination one after the another is a time consuming process• Instead, bytes can be read and stored in buffer memory before sending it to the destination• Once the buffer is full, the bytes can be sent to the destination http://improvejava.blogspot.in/ 7
  • 8. BufferedOutputStream class• This class is a subclass of FilterOutputStream• This class is used to send buffered bytes to an underlying output stream in an efficient wayConstructors • BufferedOutputStream(OutputStream outputStream) • BufferedOutputStream(OutputStream outputStream, int bufSize)• The first form creates a buffered stream using a buffer of 512 bytes. In the second form,• the size of the buffer is passed in bufSize. http://improvejava.blogspot.in/ 8
  • 9. Summary• Data stored in memory is handled by ByteArrayInputStream and is used to read bytes from a memory• ByteArrayOutputStream is used to write bytes into memory• FilteredStreams are used for converting bytes to useful forms such as char, string, int, etc http://improvejava.blogspot.in/ 9
  • 10. Quiz1. ---- is used to read bytes from a memory A. ByteArrayOutputStream B. ByteArrayInputStream C. Reader D. None http://improvejava.blogspot.in/ 10
  • 11. Quiz2. --- is used to write bytes into memory A. ByteArrayInputStream B. ByteArrayOutputStream C. Writer D. None http://improvejava.blogspot.in/ 11
  • 12. Frequently Asked Questions1. Write about ByteArrayInput and ByteArrayOutput streams2. Write about FilteredByte Streams http://improvejava.blogspot.in/ 12