Forums Register Login

byte array to string conversion?

+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send



Regards
Gopinath
I love a woman who dresses in stainless steel ... and carries tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1173 times.
Similar Threads
How to upload a byte array into BLOB column?
Converting a two dimensional int array into a byte array
Audio format conversion problems
JPasswordField.getPassword() method
regular expression doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:21:34.