Thursday, June 27, 2013

How to convert text to binary in Java

Convert String to Binary in Java


public class TexttoBinary {
  private static final int maxBytes = 3;
  public static void main(String[] args) {
  BufferedReader in = 
  new BufferedReader(new InputStreamReader(;
  do {
  try {
  System.out.print("Type the number to parse: ");
  int number = Integer.parseInt(in.readLine());
  int Bit;
  String result = "";
  for (int i = maxBytes*8; i >= 0; i--) {
  Bit = 1 << i;
  if (number >= Bit) {
  result += 1;
  number -= Bit;
  else {
  result += 0;
  catch (NumberFormatException e) {
  catch (IOException e) {
  while (true);

How to convert binary to text in Java
java: converting binary to text?
Convert String to Binary 
Thread: Converting a string of binary to data, to save to a ...
Thread: conversion text-binary-text
converting binary to string
Thread: Convert String to Binary equivalent
Java: Convert a binary file to text and back again
Searches related to convert text to binary java
java string to binary conversion
java convert binary to string
java binary decimal conversion
convert binary to text linux
convert binary file to text
convert binary to text sql
convert binary to text c++
converting integer binary java