SQL with Manoj


Home | Pages | Archives


Java Program to read from byte array using ByteArrayInputStream and print the characters onto console – Q36

January 18, 2009 8:00 am


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):


Posted by Manoj Pandey

Categories: Java

Tags: ,

Leave a Reply



Mobile Site | Full Site


Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.