Java Hex Dump hexDump(PrintStream out, String s, byte b[], int n)

Here you can find the source of hexDump(PrintStream out, String s, byte b[], int n)

Description

hex Dump

License

Open Source License

Declaration

static void hexDump(PrintStream out, String s, byte b[], int n) 

Method Source Code

//package com.java2s;

import java.io.PrintStream;

public class Main {
    static PrintStream strDump;

    static void hexDump(PrintStream out, String s, byte b[], int n) {
        if (out == null)
            return;
        int i;//  ww  w.j  a v  a 2 s  . co  m

        out.print(s);
        for (i = 0; i < n; ++i) {
            int x = b[i];
            if (x < 0)
                x = 256 + x;
            s = Integer.toString(x, 16);
            if (s.length() == 1)
                s = "0" + s;
            out.print(s);
        }
        out.println();
    }

    static void hexDump(String s, byte b[], int n) {
        hexDump(strDump, s, b, n);
    }
}

Related

  1. hexdump(byte[] bytes, OutputStream out)
  2. hexDump(byte[] data)
  3. hexDump(InputStream is, OutputStream os)
  4. hexDump(InputStream is, PrintStream ps, int maxRead, int bytesPerLine)
  5. hexDump(String prompt, byte[] bs)
  6. hexDumpBytes(PrintStream out, long offset, byte[] bytes)