Click here to watch in Youtube :
https://www.youtube.com/watch?v=5Tq1G2K5xaM&list=UUhwKlOVR041tngjerWxVccw
ByteArrayInputStreamDemo.java
Output
https://www.youtube.com/watch?v=5Tq1G2K5xaM&list=UUhwKlOVR041tngjerWxVccw
ByteArrayInputStreamDemo.java
import java.io.ByteArrayInputStream; import java.io.IOException; public class ByteArrayInputStreamDemo { public static void main(String[] args) throws IOException { String str = "abcdefghijklmnopqrstuvwxyz"; byte[] byteArray = str.getBytes(); ByteArrayInputStream byteArrayInputStream1 = new ByteArrayInputStream(byteArray); /* * The byteArrayInputStream1 contains all letters. */ displayContent(byteArrayInputStream1); ByteArrayInputStream byteArrayInputStream2 = new ByteArrayInputStream(byteArray, 0, 3); /* * The byteArrayInputStream2 contains only the first * three letters. */ displayContent(byteArrayInputStream2); } private static void displayContent(ByteArrayInputStream byteArrayInputStream) { int ch; while ((ch = byteArrayInputStream.read()) != -1) { System.out.print((char) ch); } System.out.println(); } }
abcdefghijklmnopqrstuvwxyz abc
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_ByteArrayIS_Cons_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_ByteArrayIS_Cons_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d261aab7f0b47dd247e532c02763fe1d7053f5d3/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/?at=master
See also:
No comments:
Post a Comment