Solved

How to convert 8 bit binary string to decimal or integer or ASCII code

Posted on 2002-03-21
1
1,057 Views
Last Modified: 2012-08-14
How to convert 8 bit binary string to ASCII code.
what i want something like this

01010011 01100101 01100011 01110010 01100101 01110100 00100001

convert it of this to ascii code
0
Comment
Question by:dxding
1 Comment
 
LVL 9

Accepted Solution

by:
Venci75 earned 300 total points
ID: 6885922
try this:
String src = "01010011 01100101 01100011 01110010 01100101 01110100 00100001";
java.util.StringTokenizer tok = new java.util.StringTokenizer(src, " ");
StringBuffer res = new StringBuffer();
while (tok.hasMoreTokens()) {
    char c = (char) Integer.parseInt(tok.nextToken(), 2);
    res.append(c);
}
System.out.println(res.toString());
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question