Array IO Stream


Array IO Stream

Array IO Stream:

Array IO Streams are a type of Source Facing Streams, where both Input and Output Array IO Streams points to an Array in Memory as its Source or Destination.


Below is an example of a ByteArrayInputStream which takes an Array (Source) as a constructor parameter and READ's from the following :- 




// Creating the SOURCE (Array)
  byte[] byteArray = "Array Stream Makes Little Sense".getBytes();

// Creating a ByteArrayInputStream object by passing the Source
  ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);

// Reading from the SOURCE/Array 
  int eachRead;
  while( (eachRead = byteArrayInputStream.read()) != -1 )
  {
   System.out.print((char)eachRead);
  }

<< Buffered IO Stream Object IO Stream >>

No comments:

Post a Comment