Dillinger4
Jul 19th, 2001, 11:19 AM
I just wrote a quick hack to try and get a char's byte equivalent but im not sure if the output is correct.
a comes up as [B@50bd4d
b comes up as [B@3c4459
c comes up as [B@2b6651
i was expecting to see two bytes for each char ie.... 10101110 10101010
there not the character encoding because that is being returned by the getEncoding() method. so what are they?
thanks.....
import java.io.*;
public class getbytes{
public static void main(String[] args){
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(isr); // to get readLine() method
String comline;
System.out.println(" Character encoding is " + isr.getEncoding());
try{
do{
comline = buf.readLine();
buffer = comline.getBytes();
System.out.println(buffer);
}while(comline.length() != 0);
}catch(IOException e){System.out.println("Exception caught");}
}
}
a comes up as [B@50bd4d
b comes up as [B@3c4459
c comes up as [B@2b6651
i was expecting to see two bytes for each char ie.... 10101110 10101010
there not the character encoding because that is being returned by the getEncoding() method. so what are they?
thanks.....
import java.io.*;
public class getbytes{
public static void main(String[] args){
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(isr); // to get readLine() method
String comline;
System.out.println(" Character encoding is " + isr.getEncoding());
try{
do{
comline = buf.readLine();
buffer = comline.getBytes();
System.out.println(buffer);
}while(comline.length() != 0);
}catch(IOException e){System.out.println("Exception caught");}
}
}