116 Program to demonstrate ByteArrayInputStream in Java

Code:
/*
Program to demonstrate ByteArrayInputStream in Java
*/

import java.io.*;

class ByteDemo
{
public static void main(String args[]) throws IOException
{
String data = "codingatharva.blogspot.com";

ByteArrayInputStream bais = new ByteArrayInputStream( data.getBytes() );

int ch = bais.read();

while(ch != -1)
{
System.out.print((char)ch);

ch = bais.read();
}

bais.close();
}
}

Ouput:

ByteArrayInputStream in Java

Previous
Next Post »