Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Byte Stream to String Conversion

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Byte Stream to String Conversion

    Hi All,

    Please help me to resolve my problem.

    I am getting byte stream as below. These looks like UTF 8 bytes
    3C524F4F543E3C535452494E473E54455354204F4E4C5920535452494E473C2F535452494E473E3C2F524F4F543E

    I want java code which will convert above bytes to string as shown below

    <ROOT>
       <STRING>TEST ONLY STRING</STRING>
    </ROOT>

    Much appreciate your valuable help.


    Thanks
    Raj


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,373
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Byte Stream to String Conversion

    What type of data is the byte stream in? What you have posted looks like a String.
    Are you asking how to convert a String of hex characters into another String where each 2 hex characters is converted to a character?
    The methods:
    substring() to get each 2 hex characters
    an Integer class method to convert that 2 char String into a int
    cast to get the char value from that int
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Raj4Smile (April 17th, 2014)

  4. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Byte Stream to String Conversion

    Hi Norm, this is resolved.

    Thanks
    Raj

Similar Threads

  1. Replies: 1
    Last Post: January 7th, 2014, 07:46 AM
  2. Replies: 1
    Last Post: April 7th, 2011, 01:32 PM
  3. RSA Decryption with Java.security - Hex to dec to byte array conversion...
    By SeanSeanston in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 15th, 2010, 08:48 AM
  4. UTF - 8 / Byte Stream
    By JavaCODER in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: October 16th, 2010, 02:26 PM
  5. [SOLVED] utf-16 byte[] to string conversion
    By Gerhardl in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 25th, 2010, 06:06 AM