iForeRunner
 
   
 
  JAVA  
   
   
   
 
  Java | IO| ByteArrayInputStream |example  
 
 
ByteArrayInputStream example in Java


import java.io.ByteArrayInputStream;

import java.io.FileInputStream;

/**

* www.iforerunner.com

*

*/

/**

* @author venugopal darur

*

*/

public class ByteArrayInputStreamDemo {

/**

*

*/

public ByteArrayInputStreamDemo() {

// TODO Auto-generated constructor stub

}

/**

* @param args

*/

public static void main(String[] args) {

String name="http://www.iforerunner.com";

// convert string to array of bytes

byte [] nameBytes=name.getBytes();

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(nameBytes);

int bytes;

while((bytes=byteArrayInputStream.read())!=-1){

System.out.println((char) bytes);

}

}

}

Output:
 

h t t p : / / w w w . i f o r e r u n n e r . c o m

Please send comments to vgdarur.javafive@blogger.com