Java Byte Array Dump dumpBytes(byte[] byts, int offset, int length)

Here you can find the source of dumpBytes(byte[] byts, int offset, int length)

Description

Get printable representation of bytes in array.

License

Open Source License

Parameter

Parameter Description
byts bytes
offset starting position
length number of bytes

Return

text printable representationt

Declaration

public static String dumpBytes(byte[] byts, int offset, int length) 

Method Source Code

//package com.java2s;

public class Main {
    private static String s_hexChars = "0123456789abcdef";

    /**/*from w ww.  j ava2s. co m*/
     * Get printable representation of bytes in array.
     * 
     * @param byts bytes
     * @param offset starting position
     * @param length number of bytes
     * @return text printable representationt
     */
    public static String dumpBytes(byte[] byts, int offset, int length) {
        StringBuffer buff = new StringBuffer(length * 3);
        for (int i = 0; i < length; i++) {
            buff.append(' ');
            byte byt = byts[offset + i];
            buff.append(s_hexChars.charAt((byt >> 4) & 0xF));
            buff.append(s_hexChars.charAt(byt & 0xF));
        }
        return buff.toString();
    }
}

Related

  1. dumpBytes(byte[] bytes)
  2. dumpBytes(byte[] bytes)
  3. dumpBytes(byte[] bytes)
  4. dumpBytes(byte[] bytes, int maxLen)
  5. dumpBytes(byte[] bytes, int start, int length)
  6. dumpBytes(byte[] data)
  7. dumpBytes(byte[] data)
  8. dumpBytes(final byte[] bytes)
  9. dumpBytes(String headerStr, byte[] bytes)