Java Hex to String

Posted on 2007-11-19
Last Modified: 2013-12-22

I want to convert a Hex String to String.
Example input:


Example output:

Thanks from now!
Question by:CSecurity
LVL 26

Expert Comment

ID: 20311849
I don't think you can do that! there should be some delemeter between each char representation...
LVL 17

Author Comment

ID: 20311859
Hex maximum length is 2
LVL 17

Author Comment

ID: 20311861
and for hex with length 1 there will be zero before it
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 13

Accepted Solution

Bart Cremers earned 500 total points
ID: 20311909
Here's a method for use with fixed lengths. Usage:

    hexToString("41424344", 2)
    public static String hexToString(String input, int groupLength) {

        StringBuilder sb = new StringBuilder(input.length() / groupLength);

        for (int i = 0; i < input.length() - groupLength + 1; i += groupLength) {

            String hex = input.substring(i, i + groupLength);

            sb.append((char) Integer.parseInt(hex, 16));


        return sb.toString();


Open in new window

LVL 86

Expert Comment

ID: 20311970

String s = new String(new BigInteger("41424344").toByteArray()));

Open in new window

LVL 86

Expert Comment

ID: 20311987
String s = new String(new BigInteger("41424344", 16).toByteArray()));

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now