Results 1 to 3 of 3
  1. #1
    stegano is offline Member
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    0

    Default conversion text-binary-text

    Hi,
    I have made a code to convert text to binary.
    the problem is I don't know how to convert it back to text.
    so I really need your help. please. anyone?

    XML Code:
    import java.util.*;
    public class textToBinary{
    
    public static void main(String[] args) {
    
    
    		Scanner input = new Scanner(System.in);
    		
    		System.out.println("enter text");
    		String text = input.nextLine();
    		
    		byte[] bytes = text.getBytes();
      		StringBuilder binary = new StringBuilder();
      		for (byte b : bytes) {
         			int val = b;
         			for (int i = 0; i < 8; i++) {
            			binary.append((val & 128) == 0 ? 0 : 1);
            			val <<= 1;
    		//System.out.println(binary);
    		
         			}
         			
      	}System.out.println(binary);
    }
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Double post of
    converting binary to string

    db

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Image file to Text Conversion
    By sureshsoftengg in forum New To Java
    Replies: 2
    Last Post: 09-21-2010, 12:08 PM
  2. Converting a text file int binary
    By sruthi_2009 in forum New To Java
    Replies: 0
    Last Post: 03-23-2009, 03:09 PM
  3. Binary text
    By bizmut in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-24-2008, 02:50 AM
  4. Text to XML conversion
    By tarandeep.singh in forum XML
    Replies: 1
    Last Post: 06-14-2008, 02:17 AM
  5. HSSF: Html to Text conversion
    By xtech in forum Advanced Java
    Replies: 1
    Last Post: 04-17-2008, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •