473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to convert binary to string

Expand|Select|Wrap|Line Numbers
  1. byte[] bytes = s.getBytes();
  2.   StringBuilder binary = new StringBuilder();
  3.   for (byte b : bytes)
  4.   {
  5.      int val = b;
  6.      for (int j = 0; j < 8; j++)
  7.      {
  8.         binary.append((val & 128) == 0 ? 0 : 1);
  9.         val <<= 1;
  10.      }
  11.      binary.append(' ');
  12.   }
in this pgm I have converted string to binary....from this pgm how can I convert it to back
Mar 30 '15 #1
0 1624

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: David Lawson | last post by:
I know how to conver a string to an array of strings, but I need to convert an ascii string to an array of integers (really unsigned chars). Eg, $str ="ABC"; needs to convert to something...
5
by: Alexander Eisenhuth | last post by:
Hallo all there, maby I don't see the forest because of all that trees, but : from struct import * # how can I convert f = float(0.5)
3
by: Eric | last post by:
Guys, I have the following hexadecimal string - '\xff\xff\xff' which i need to convert to binary. How would i go about doing this? Eric
2
by: Remi Caron | last post by:
Hi, I took over an Visual Object project (Visual Clipper) in that language there is a function to: Convert a string containing a 32-bit binary date to a date data type. That function is called...
2
by: Joey Lee | last post by:
Hi, Does anyone know how I am able to write a utf-8 encoded binary string into binary file? Currently I am given a UTF-8 string which was read from a gif image. Here are my functions... ...
4
by: Julia | last post by:
Hi, I need to convert unicode string to ansi string Thanks in adavance.
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
2
by: bilbo2000 | last post by:
I am trying to read in a binary file which has the data stored as 32 bit float. I have been trying to figure out how to read this in as 32 bit but everytime I try to read it in the best I can do...
1
by: supercooper | last post by:
I have this string that is being returned from a query on a DBISAM database. The field must be some sort of blob, and when I connect to the database thru ODBC in MS Access, the field type comes...
9
by: Leo jay | last post by:
i'd like to implement a class template to convert binary numbers to decimal at compile time. and my test cases are: BOOST_STATIC_ASSERT((bin<1111,1111,1111,1111>::value == 65535));...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.