Previous | Next | Trail Map | Writing Java Programs | Input and Output Streams


Using Streams to Read and Write Memory Locations

Use ByteArrayInputStream(in the API reference documentation)and ByteArrayOutputStream(in the API reference documentation)to read and write 8-bit data. You create these streams on an existing byte array and then use the read() and write() methods to read from or write data to the array in memory.

Use StringBufferInputStream to read data from a StringBuffer. You create a StringBufferInputStream on an existing StringBuffer object and then use the read() methods to read from the StringBuffer as it lives in memory. This stream is similar to the ByteArrayInputStream which reads 8-bit data from a byte array in memory but StringBufferInputStream reads 16-bit Unicode data from a string buffer in memory. The java.io package does not have a partner output stream for StringBufferInputStream--you can use the StringBuffer class directly instead.

See Also

java.io.ByteArrayInputStream
java.io.ByteArrayOutputStream
java.io.StringBufferInputStream


Previous | Next | Trail Map | Writing Java Programs | Input and Output Streams