import java.io.ByteArrayOutputStream;
import java.io.IOException;
// The ByteArrayInputStream class allows a buffer in the memory to be used as an InputStream.
//The input source is a byte array.
// There are following forms of constructors to create ByteArrayInputStream objects
// ByteArrayInputStream bArray = new ByteArrayInputStream(byte [] a);
// ByteArrayInputStream bArray = new ByteArrayInputStream(byte []a,int off, int len);
// METHODS
// public int read()
// public int read(byte[] r, int off, int len)
// public int available()
// public void mark(int read)
// public long skip(long n)
public class ByteArrayInputNoutputStream {
public static void main(String[] args) throws IOException {
ByteArrayOutputStream bOut = new ByteArrayOutputStream(12);
while(bOut.size() != 5){
bOut.write(System.in.read());
}
byte[] b = bOut.toByteArray();
System.out.println("Print all the entered content");
for (int i = 0; i < b.length; i++) {
System.out.print((char)b[i]+" ");
}
System.out.println(" ");
int c;
ByteArrayInputStream bIn = new ByteArrayInputStream(b);
System.out.println("Converting All the entered Characters to the upper case");
for (int i = 0; i < 1; i++) {
while((c = bIn.read()) != -1){
System.out.println(Character.toUpperCase((char)c));
}
}
}
}

No comments:
Post a Comment