how to translate letters to binary values?
Hi people,
I am very new to code writing and seeking for immidiate help :) How do I translate binary values to alphabet or the other way around?
class Binary {
public static void main(String args[])
throws java.io.IOException{
// I guess I have to define very single binray value.
// for example:
int i = 1000001, j = 1100001; //etc.
// and do the same thing for letters.
char ch = 'A', ch1 = 'a'; //etc..
//the question is how can I assign i = ch and j = ch1 ? in order to display the value of the entered binary code.. Don't laugh people :)
Re: how to translate letters to binary values?
Re: how to translate letters to binary values?
use getBytes(), then convert each byte to an int, then use the static toBinaryString() method to get the equivalent binary string.
Re: how to translate letters to binary values?
Also note that this:
int i = 1000001
is not binary.
Re: how to translate letters to binary values?
Quote:
Originally Posted by System_Error
use getBytes(), then convert each byte to an int, then use the static toBinaryString() method to get the equivalent binary string.
Hi there, Do you think I am on the right track.
class Binary {
public void getBytes(byte dst[]) or should I use public byte[] getBytes(String enc) throws UnsupportedEncodingException
public static String toBinaryString(int i)
Thx