
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert a byte array to a hex string in Java?
The printHexBinary() method of the DatatypeConverter class accepts a byte array and returns a hex string.
Example
import javax.xml.bind.DatatypeConverter; public class ByteToHexString { public static void main(String args[]) { String sam = "Hello how are you how do you do"; byte[] byteArray = sam.getBytes(); String hex = DatatypeConverter.printHexBinary(byteArray); System.out.println(hex); } }
Output
48656C6C6F20686F772061726520796F7520686F7720646F20796F7520646F
- Related Questions & Answers
- How to convert a byte array to hex string in Java?
- Convert byte Array to Hex String in Java
- Convert Hex String to byte Array in Java
- How to convert hex string to byte Array in Java?
- Java Program to convert byte[] array to String
- Java Program to convert String to byte array
- Convert a String to a byte number in Java
- How to convert a PDF to byte array in Java?
- Convert byte to String in Java
- How to convert byte array to string in C#?
- Convert Integer to Hex String in Java
- How to Convert Hex String to Hex Number in C#?
- How to convert a String to and fro from UTF8 byte array
- Java Program to convert byte to string
- Java Program to convert string to byte
Advertisements