Click here to watch in Youtube :
https://www.youtube.com/watch?v=VLuGOJfw_rE&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java IO (ByteArrayInputStream) |
Java Tutorial : Java IO (ByteArrayInputStream) |
Java Tutorial : Java IO (ByteArrayInputStream) |
import java.io.ByteArrayInputStream; import java.io.IOException; public class ByteArrayInputStreamDemo { public static void main(String[] args) throws IOException { ByteArrayInputStream byteArrayInputStream = null; try { String str = "Peter is going to India."; byte[] byteArray = str.getBytes(); byteArrayInputStream = new ByteArrayInputStream(byteArray); int ch; while ((ch = byteArrayInputStream.read()) != -1) { System.out.print((char) ch); } } finally { if (byteArrayInputStream != null) { /* * Closing a ByteArrayInputStream has no * effect. The methods in this class can be * called after the stream has been closed * without generating an IOException. */ byteArrayInputStream.close(); } } } }Output
Peter is going to India.Refer:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_ByteArrayInputStream_Intro_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/94d38fdd49b2d33c14c088526d40f902c21a1e0d/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/?at=master
See also:
No comments:
Post a Comment