Twitter Update

Using ByteArrayInputStream in java programming [ Java ]

Here I create program with using bytearrayinputstream. Where we write file, but each byte will be in array. This is the code :

import java.io.*;
public class Main {

  
    public static void main(String[] args) {
    String b="albert julius";
    byte [] ab=b.getBytes();
    ByteArrayInputStream a=new ByteArrayInputStream(ab,0,13);
    int c,i=0;
    while((c=a.read())!=-1)
    {
        if(i==0)
        {System.out.print((char) c);
        i++;
        }
        else
        {System.out.print(Character.toUpperCase((char)c));
         i--;
           }
    }
a.reset();
    }
}


0 comments:

Post a Comment

ABOUT ME

IP
Albert Julius. Powered by Blogger.
Copyright © Albert'Blog