by
0
6
3,871
2
Top 1% !
Popular
Famous
Tagged
Specified
OpenSource
Popularity: 2885th place

Published on:

InputName0input
InputType0byte[]
JVMjre1
LanguageJava
LicenseMIT_X11
MethodNameprintHexByteArray
OutputTypeString

How to print a byte array in hexadecimal form in Java

Prints the given byte array as hexadecimal string
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/113399/How-to-print-a-byte-array-in-hexadecimal?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static String printHexByteArray(byte[] input) { if (input == null) return ""; StringBuilder sbs = new StringBuilder(); for (int i = 0; i < input.length; i++) { sbs.append(String.format("%02x", input[i] & 0xff)); } return sbs.toString(); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus