Hey friends.Need a help from you again.
I'm trying to study about streams and I wrote small code for get input from command line and print it in the screen,but It prints weird characters like Japanese :O . Can anyone explain what I did wrong...
import java.io.*;
public class ReadBytes {
public static void main(String[] args) {
try{
// FileInputStream file =new FileInputStream(System.in);
BufferedInputStream buff = new BufferedInputStream(System.in);
DataInputStream data = new DataInputStream(buff);
int count=0;
try{
while(true){
char input =data.readChar();
System.out.print(input+" ");
count++;
}
}
catch(EOFException eof){
buff.close();
}
System.out.println("\nBytes read: " +count);
}catch(IOException e){
System.out.println("Error -- "+e.toString());
}
}
}
//output
baby C
扡 批 ⁃