Java Hex Print printHexBytes(byte[] _theBytes)

Here you can find the source of printHexBytes(byte[] _theBytes)

Description

print Hex Bytes

License

Open Source License

Declaration

public static String printHexBytes(byte[] _theBytes) 

Method Source Code

//package com.java2s;
/*************************************************************************
 * /*from  w ww. ja  v  a 2 s .  c o m*/
 *  Copyright 2009 by Giuseppe Castagno beppec56@openoffice.org
 *  
 *  The Contents of this file are made available subject to
 *  the terms of European Union Public License (EUPL) version 1.1
 *  as published by the European Community.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the EUPL.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  EUPL for more details.
 *
 *  You should have received a copy of the EUPL along with this
 *  program.  If not, see:
 *  https://www.osor.eu/eupl, http://ec.europa.eu/idabc/eupl.
 *
 ************************************************************************/

import java.util.IllegalFormatException;

public class Main {
    public static String printHexBytes(byte[] _theBytes) {
        String _sRet = "";
        for (int i = 0; i < _theBytes.length; i++) {
            if (i != 0 && i % 16 == 0)
                _sRet = _sRet + " \n";
            try {
                _sRet = _sRet
                        + String.format(" %02X", (_theBytes[i] & 0xff));
            } catch (IllegalFormatException e) {
                e.printStackTrace();
            }
        }
        return _sRet;
    }
}

Related

  1. printHex(byte[] bytes)
  2. printHex(byte[] bytes)
  3. printHex(byte[] data)
  4. printHex(byte[] field, int start, int len)
  5. printHexa(final byte b)
  6. printHexNumber(int n)
  7. printHexString(byte[] b)
  8. printHexString(final StringBuilder sb, final String hexData)