Click here to watch in Youtube :
https://www.youtube.com/watch?v=4JAld7HOHJU&list=UUhwKlOVR041tngjerWxVccw
ByteArrayOutputStreamDemo.java
Outputhttps://www.youtube.com/watch?v=4JAld7HOHJU&list=UUhwKlOVR041tngjerWxVccw
ByteArrayOutputStreamDemo.java
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; public class ByteArrayOutputStreamDemo { public static void main(String[] args) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); System.out.println("Enter the chars:"); while (byteArrayOutputStream.size() != 4) { // Gets the inputs from the user byteArrayOutputStream.write(System.in.read()); } byte[] byteArray = byteArrayOutputStream.toByteArray(); System.out.println("\nPrint the content"); for (int x = 0; x < byteArray.length; x++) { // printing the characters System.out.print((char) byteArray[x] + " "); } System.out.println(" \n"); int c; ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); System.out.println("Converting characters to Upper case "); for (int y = 0; y < 1; y++) { while ((c = byteArrayInputStream.read()) != -1) { System.out.print(Character.toUpperCase((char) c) + " "); } } } }
Enter the chars: abcd Print the content a b c d Converting characters to Upper case A B C D
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_ByteArrayOS_ByteArrayIS_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d261aab7f0b47dd247e532c02763fe1d7053f5d3/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/?at=master
See also:
No comments:
Post a Comment