• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String into byte buffer

 
chella adisesh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Wanted to know how to convert a string into a byte buffer.
Also can someone give me links or books to -
* converting byte buffer to string.
* converting string to bytebuffer.
* converting string to string buffer.
* converting string to char buffer.
Thanks.
Chella
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the javadoc on
String
StringBuffer
especially String.getBytes(), String.getChars() and String(bytes[])
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Previously you were asking about ByteBuffer and CharBuffer. (Capitalization is important in Java.) You can convert a String to a CharBuffer using CharBuffer.wrap(CharSequence) (note that a String is also a CharSequence) and then you can use a CharsetEncoder to convert the CharBuffer to a ByteBuffer. It's much like the answer to your previous question, but in reverse. Study the APIs for the classes and methods that have been mentioned here; they contain explanations for how each of these works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic