Java Array Dump dumpMessage(byte b[])

Here you can find the source of dumpMessage(byte b[])

Description

dump Message

License

Open Source License

Declaration

public static String dumpMessage(byte b[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String dumpMessage(byte b[]) {
        return dumpMessage(b, 0, b.length);
    }/*w w w. j av  a2 s . c  o m*/

    public static String dumpMessage(byte b[], int pos, int len) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        for (int i = pos; i < len; i++)
            switch (b[i]) {
            case 2: // '\002'
                sb.append("&STX;");
                break;
            case 3: // '\003'
                sb.append("&ETX;");
                break;
            case 27: // '\033'
                sb.append("&ESC;");
                break;
            default:
                sb.append((char) b[i]);
                break;
            }
        sb.append(']');
        return sb.toString();
    }
}

Related

  1. dumpHexString(final byte[] array)
  2. dumpInt(String name, int[] src)
  3. dumpIntArray(int[] A, int n)
  4. dumpIntArray(int[] data, String label)
  5. dumpMatrix(byte[] matrix, int numDataUnits, int numAllUnits)
  6. dumpOctets(byte[] data)
  7. dumpPosition(long[] position)
  8. dumpStackTrace(StackTraceElement[] elements)
  9. dumpString(byte[] b)