Java Byte Array to Hex bytesToHex(StringBuffer buff, byte[] src, int start, int end)

Here you can find the source of bytesToHex(StringBuffer buff, byte[] src, int start, int end)

Description

bytes To Hex

License

Open Source License

Declaration

private static void bytesToHex(StringBuffer buff, byte[] src, int start, int end) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *                       I N T E L   C O R P O R A T I O N
 * /*from  w  w  w .ja  v a  2 s  . co  m*/
 *  Functional Group: Fabric Viewer Application
 * 
 *  File Name: StringUtils.java
 * 
 *  Archive Source: $Source$
 * 
 *  Archive Log: $Log$
 *  Archive Log: Revision 1.8  2015/08/17 18:48:51  jijunwan
 *  Archive Log: PR 129983 - Need to change file header's copyright text to BSD license txt
 *  Archive Log: - change backend files' headers
 *  Archive Log:
 *  Archive Log: Revision 1.7  2015/06/10 19:36:43  jijunwan
 *  Archive Log: PR 129153 - Some old files have no proper file header. They cannot record change logs.
 *  Archive Log: - wrote a tool to check and insert file header
 *  Archive Log: - applied on backend files
 *  Archive Log:
 * 
 *  Overview:
 * 
 *  @author: jijunwan
 * 
 ******************************************************************************/

public class Main {
    private static void bytesToHex(StringBuffer buff, byte[] src, int start, int end) {
        String groupSeparator = "";
        for (int i = start; i < end; i = i + 2) {
            buff.append(groupSeparator);
            int group = ((src[i] << 8) & 0xff00) | ((src[i + 1]) & 0xff);
            buff.append(Integer.toHexString(group));
            groupSeparator = ":";
        }
    }
}

Related

  1. bytesToHex(final byte[] bytes)
  2. bytesToHex(final byte[] bytes)
  3. bytesToHex(final byte[] bytes)
  4. bytesToHex(final byte[] bytes, final boolean toLowerCase)
  5. bytesToHex(final byte[] bytes, final int position, final int length)
  6. bytesToUnsignedHexes(byte[] bytes)
  7. byteToBcd(byte src)
  8. byteToHex(byte b)
  9. byteToHex(byte b)