Home
> Java > Java Program to read from byte array using ByteArrayInputStream and print the characters onto console – Q36
Java Program to read from byte array using ByteArrayInputStream and print the characters onto console – Q36
Q36: Java Program to read from byte array using ByteArrayInputStream and print the characters onto console.
import java.io.*;
import javax.swing.*;
class B_a_i_s{
public static void main(String args[]){
String inp = JOptionPane.showInputDialog("Enter a String:");
byte b_arr[] = inp.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(b_arr);
int c;
while((c = in.read()) != -1){
System.out.print((char)c);
}
}
}
… from College notes (BCA/MCA assignments):
Categories: Java
Java File Handling, Java IO Programs
Comments (0)
Trackbacks (0)
Leave a comment
Trackback




