In this section, we will learn how to convert Text to Binary. The following program provides you the functionality to convert Text to Binary.
Convert Text to Binary
In this section, we will learn how to convert Text to Binary. The following program provides you the functionality to convert Text to Binary.
Code Description:
In the program code below, to take the input from the keyboard we have used BufferReader() method in which we have passed an object of it which is InputStreamReader() as must be knowing. Then we have defined a variable of type int which will convert the input to integer line by line. Now we have used a loop here to check the number we well input. It will take maximum of 24 bytes as we have declared maxBytes=3. Hence it will convert the number into bytes one by one.
Here is the code of the program:
import java.io.*;
|
Output of the program:
C:\unique>javac TexttoBinary.java C:\unique>java TexttoBinary Type the number to parse: 417893 0000001100110000001100101 Type the number to parse: 3289 0000000000000110011011001 Type the number to parse: |