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 6763501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:00+00:00 2026-05-26T14:29:00+00:00

In my Java Program, I need a byte array from a Hex String. So

  • 0

In my Java Program, I need a byte array from a Hex String. So I do the following:

byte[] key=HexUtils.convert("0AA387ED291F6D90");

This converts the Hex String into a byte array as follows:

Output: Byte Array: key:[10, -93, -121, -19, 41, 31, 109, -112]

Now, I want to move the Hex String into the properties file. But I am not able to do so.

Try 1:
Properties file ====> key=0AA387ED291F6D90
Java Program ====> byte[] key = HexUtils.convert(prop.getProperty("key"));

This gives error: BAD HEXADECIMAL DIGIT

Try 2:
Properties file ====> key=\u000A\u00A3\u0087\u00ED\u0029\u001F\u006D\u0090
Java Program ====> byte[] key = HexUtils.convert(prop.getProperty("key"));

Output: key:[10, -93, 63, -19, 41, 31, 109, 63]

If you notice, 2 bytes are different than the Expected. Hex 87 and Hex 90. Both are converted to 63. Whereas I am expecting -121 and -112 respectively.

Can somebody please help me as to how do I do this conversion. I hope I am clear!

Angad

  • 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-05-26T14:29:01+00:00Added an answer on May 26, 2026 at 2:29 pm

    If using the \uxxxx codes, you’re using UNICODE escape sequences. \u0090 is not going to end up being interpreted as String "90", it’s gonna end up as a single character that corresponds to code unit 0090 in the UTF-16 encoding.

    Your first approach should work. I suggest you try System.out.println(prop.getProperty("key")); or some other form of output and check if there’s leading or trailing white space, some character you didn’t expect or null. The latter would mean the property for “key” isn’t found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run this line from my c++ program: java -jar test.jar text1
I currently have the following array in a Java program, byte[] data = new
I have a number of byte[] array variables I need to convert to string
I need to call some methods in Wininet.dll from a Java program. I can
I need to see the query being sent to Oracle from a Java program.
I need to run a string through a Java program and then retrieve the
I have a Java program and I need to create a Windows Service from
I need to run a couple of other programs from my own Java program,
I need to edit format for JFormatedTextField in a Java program. NetBeans are helping
I need to write a Perl script that pipes input into a Java program.

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.