Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8214131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:21:19+00:00 2026-06-07T11:21:19+00:00

I have a String array that actually consists of Hex characters. Let’s say the

  • 0

I have a String array that actually consists of Hex characters.

Let’s say the contents are ->

String array[] = {8C,D9,26,1D,69,B7,96,DB};  

Now I want these to be interpreted as Hex characters of 1 byte each and not as a String where each entry is 2 bytes.

StringBuilder output = new StringBuilder();
for (int j = 0; j < array.length; j++) {
        String temp = "\u00"+ array[j];
        output.append(temp);
    }

Tried something like that, but it’s not possible because it keeps complaining about “illegal unicode escape”. I tried using “\u00” (i.e. two backslashes before u, but stackoverflow displays only one there) instead of “\u00” to get around that error, but then I don’t see the real Hex values in the array, instead I see a bunch of strings like -> “\U008C” , “\U00D9” and so on..

I want the after conversion values to be 0x8C, 0xD9, 0x26…

Thanks.

EDIT: I have updated the question, just to clarify there were no commas in the array itself. And eventually I need to put all those values together, and use that as a HMAC key that is a hex string and NOT a text string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:21:21+00:00Added an answer on June 7, 2026 at 11:21 am

    Let the JDK do the work for you:

    String[] array = {"8C", "D9", "26", "1D", "69", "B7", "96", "DB"};
    
    StringBuilder output = new StringBuilder();
    for ( String hex : array ) {
        output.append( (char)Integer.parseInt( hex, 16 ) );
    }
    

    Basically just that one line inside the loop is all you need.

    If you wanted your input to be just one big String (which would seem more convenient), just do this instead:

    String input = "8CD9261D69B796DB";
    
    StringBuilder output = new StringBuilder();
    for ( String hex : input.replaceAll( "..(?!$)", "$0," ).split( "," ) ) {
        output.append( (char)Integer.parseInt( hex, 16 ) );
    }
    

    Edited:

    If you want byte[] result, do this:

    String[] array = {"8C", "D9", "26", "1D", "69", "B7", "96", "DB"};
    
    byte[] bytes = new byte[array.length];
    for ( int i = 0; i < array.length; i++ ) {
        bytes[i] = (byte)Integer.parseInt( array[i], 16 );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string that look like Array that fetched from other webservice like this
I have to compare a value in a string array to that of a
I have a string that has been converted into an 2D Array in js.
i have this code that will check the array contains the specific string and
I have an array of strings that I want to use for button titles
Using VB.NET - I have a string: ##RES00012##Some value ##RES00034##Another value That I want
I have an array of type string which I want to re-use inside a
I have an ActiveRecord model that has a long string field. Actually, this string
I have a hashmap that contains multiple string arrays. I am trying to output
I have a mutable array that is retained and storing several objects. At some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.