View Single Post
  #8 (permalink)  
Old 01-12-2009, 06:56 PM
Steve11235's Avatar
Steve11235 Steve11235 is offline
Senior Member
 
Join Date: Dec 2008
Posts: 967
Rep Power: 2
Steve11235 is on a distinguished road
Default
All streams have a source, typically a file or a socket connection. In your song example, the song could come from an MP3 file on your hard drive or from a download service via the Internet. These streams will read in data to a buffer until it is full, then wait for you to read the contents. Once you read, the stream will put more data in the buffer.

ByteArrayInputStream is a *special* in-memory stream, where the input to the stream is a byte array that was already created. In your song example, you would have already have read the bytes into memory by some other means.

From what you are saying, I'm guessing you want to read a song from a file on your disk. In that case, use a FileInputStream wrapped by a BufferedInputStream. Then use the read(byte[] buffer) method to put bytes into the buffer (which you created previously).
Reply With Quote