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