This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting bytes to string and vice versa  RSS feed

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see following write and read methods. When read the bytes and convert them to string, I don't see the same String that I wrote. I know its a basic file read question but how do I convert those bytes to same String as it was before I wrote it?

Thanks
Imad

 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some useful advice, not just for Android, but for Java in general: Never, ever, use "String.getBytes()" or "new String(byte[])" - always be explicit about encodings.
 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!