Java Byte Array to Hex bytesToHex(byte[] bytes)

Here you can find the source of bytesToHex(byte[] bytes)

Description

bytes To Hex

License

Open Source License

Declaration

public static String bytesToHex(byte[] bytes) 

Method Source Code

//package com.java2s;
/*/*from  ww  w .ja v a  2 s.  co  m*/
(C) 2007 Stefan Reich (jazz@drjava.de)
This source file is part of Project Prophecy.
For up-to-date information, see http://www.drjava.de/prophecy
    
This source file is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, version 2.1.
*/

public class Main {
    public static String bytesToHex(byte[] bytes) {
        StringBuilder stringBuilder = new StringBuilder(bytes.length * 2);
        for (int i = 0; i < bytes.length; i++) {
            String s = "0" + Integer.toHexString(bytes[i]);
            stringBuilder.append(s.substring(s.length() - 2, s.length()));
        }
        return stringBuilder.toString();
    }
}

Related

  1. bytesToHex(byte[] bt)
  2. bytesToHex(byte[] buf)
  3. bytesToHex(byte[] bytes)
  4. bytesToHex(byte[] bytes)
  5. bytesToHex(byte[] bytes)
  6. bytesToHex(byte[] bytes)
  7. bytesToHex(byte[] bytes)
  8. bytesToHex(byte[] bytes)
  9. bytesToHex(byte[] bytes)