3

I use Java8 and I wonder if Java8 has an equivalent method to org.apache.commons.codec.Hex.encodeHexString

Thanks!

0

2 Answers 2

1

Integer.toHexString(int) is available. As is BigInteger.toString(int radix). Both can encode to hex.

Sign up to request clarification or add additional context in comments.

2 Comments

Hex.encodeHexString() - input is a byte[] and output is String.
Just telling you what is available built-in.
0

It is hard to tell what you really need without seeing example of input and expected output, but based on your comment under @Elliott's answer:

Hex.encodeHexString() - input is a byte[] and output is String.

you may be looking for HexBinaryAdapter class and its

  • String marshal(byte[] bytes)
  • byte[] unmarshal(String s)

methods (although they are non-static so you will need instance of this adapter).


They internally invoke these static methods:

  • DatatypeConverter.printHexBinary(bytes)
  • DatatypeConverter.parseHexBinary(s)

So you may want to take a look at DatatypeConverter class.

1 Comment

I will try it and let you know :-) Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.