• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

byte array to string conversion?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Regards
Gopinath
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic