Two Laptop Bag*
The moose likes Java Micro Edition and the fly likes byte array to string conversion? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "byte array to string conversion?" Watch "byte array to string conversion?" New topic
Author

byte array to string conversion?

Gary Nitzberg
Greenhorn

Joined: Aug 15, 2011
Posts: 4
I am trying to move a buffered image and I'm running into a String/Byte conversion problem.
Here is an example of where my understanding breaks down.
Can some explain why converting a string to and from a byte array, the length and data in the variables appears to be modified?
TIA.


CODE:
String testString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
byte[] testBytes = testString.getBytes();
String backToString = testBytes.toString();

System.out.println ("Length of testString: " + testString.length() );
System.out.println ("Length of testBytes: " + testBytes.length );
System.out.println ("Length of backToString: " + backToString.length() );
System.out.println ("backToString data: " + backToString );


RESULTS:
Length of testString: 26
Length of testBytes: 26
Length of backToString: 11
backToString data: [B@1cb37664

Gopinath Karyadath
Ranch Hand

Joined: Oct 14, 2009
Posts: 87



Regards
Gopinath
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: byte array to string conversion?
 
Similar Threads
Audio format conversion problems
Converting a two dimensional int array into a byte array
How to upload a byte array into BLOB column?
JPasswordField.getPassword() method
regular expression doubt