How to display bytes in the same way in Java and Python

When acquiring or processing binaries stored in the data store with Python and Java (Scala) In both cases, the way bytes are displayed is different and the comparison is troublesome, so I investigated how to display them in the same way.

Python

print(b"abcde".hex())

Java In println, the contents of byte [] cannot be displayed, and if you display each element with a for statement, it will be signed unlike Python, so it was quite troublesome, but you can display it in the same way below.

import java.math.BigInteger;

byte[] bytes = "abcde".getBytes();
System.out.printf("%x%n", new BigInteger(1, bytes));

Both are output as shown below.

6162636465

Recommended Posts

How to display bytes in the same way in Java and Python
[Note] How to write QR code and description in the same image with python
How to display multiplication table in python
How to display Hello world in python
How to use is and == in Python
[Super easy! ] How to display the contents of dictionaries and lists including Japanese in Python
How to use the C library in Python
How to generate permutations in Python and C ++
[Python] How to change the date format (display format)
How to get the files in the [Python] folder
I want to display the progress in Python!
How to plot autocorrelation and partial autocorrelation in python
[Python] How to specify the window display position and size of matplotlib
How to write the correct shebang in Perl, Python and Ruby scripts
How to get the date and time difference in seconds with python
How to retrieve the nth largest value in Python
How to get the variable name itself in python
How to get the number of digits in Python
How to measure processing time in Python or Java
How to know the current directory in Python in Blender
[Python] How to sort dict in list and instance in list
How to use the model learned in Lobe in Python
How to develop in Python
[Python] How to output the list values in order
How to get a list of files in the same directory with python
How to use Python bytes
[Mac] A super-easy way to execute system commands in Python and output the results
[python] How to check if the Key exists in the dictionary
How to debug the Python standard library in Visual Studio
Application to display and search local memos (diary) in Python
How to use the __call__ method in a Python class
How to use pyenv and pyenv-virtualenv in your own way
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
Display numbers and letters assigned to variables in python print
A standard way to develop and distribute packages in Python
I tried programming the chi-square test in Python and Java.
Comparison of how to use higher-order functions in Python 2 and 3
How to get the last (last) value in a list in Python
[Python] Display the elapsed time in hours, minutes, and seconds (00:00:00)
How to get all the keys and values in the dictionary
I tried to enumerate the differences between java and python
How to execute external shell scripts and commands in python
Graph the Poisson distribution and the Poisson cumulative distribution in Python and Java, respectively.
[Python] How to do PCA in Python
How to collect images in Python
In the python command python points to python3.8
How to get the Python version
[Python] How to import the library
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to handle Japanese in Python
How to do "Lending and borrowing JS methods (the one who uses apply)" in Python
How to check if the contents of the dictionary are the same in Python by hash value
An easy way to view the time taken in Python and a smarter way to improve it
An easy way to hit the Amazon Product API in Python
Determine the date and time format in Python and convert to Unixtime
How to handle multiple versions of CUDA in the same environment
How to determine the existence of a selenium element in Python
How to install OpenCV on Cloud9 and run it in Python