Java Hex Calculate toHex(byte b)

Here you can find the source of toHex(byte b)

Description

to Hex

License

Open Source License

Parameter

Parameter Description
b byte

Return

String

Declaration

static public String toHex(byte b) 

Method Source Code

//package com.java2s;
/**/*  w  w  w  . j a v a2  s .c o  m*/
 * Copyright (C) 2008 ITS of ETH Zurich, Switzerland, Sarah Windler Burri
 * <p>
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option) any
 * later version.
 * <p>
 * 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.
 * <p>
 * See the GNU Lesser General Public License for more details. You should have
 * received a copy of the GNU Lesser General Public License along with this
 * program; if not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * @param b byte
     * @return String
     */
    static public String toHex(byte b) {
        String st = Integer.toHexString(b);
        return (st.length() == 1) ? "0" + st : st;
    }
}

Related

  1. toHex(byte b)
  2. toHex(byte b)
  3. toHex(byte b)
  4. toHex(byte b)
  5. toHex(byte b)
  6. toHex(byte b)
  7. toHex(byte b)
  8. toHex(byte b)
  9. toHex(byte b, char[] charArray, int from)