Java Byte to String byteToString(int b)

Here you can find the source of byteToString(int b)

Description

Convert a byte to a human readable representation

License

Open Source License

Parameter

Parameter Description
b the byte

Return

the human readable representation

Declaration

public static String byteToString(int b) 

Method Source Code

//package com.java2s;
/*//from   ww w.j  ava 2  s.c om
 *  This file is part of Gjokii.
 *
 *  Gjokii 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.
 *
 *  Gjokii 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
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Gjokii.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Convert a byte to a human readable representation
     * 
     * @param b
     *            the byte
     * @return the human readable representation
     */
    public static String byteToString(int b) {
        String s = Integer.toHexString(b);
        if (s.length() == 1)
            s = "0" + s;
        else
            s = s.substring(s.length() - 2);
        return s;
    }
}

Related

  1. byteToString(byte b)
  2. byteToString(byte b)
  3. ByteToString(byte b)
  4. byteToString(byte b_)
  5. byteToString(int b)
  6. byteToString(int b)
  7. ByteToString(int b)
  8. byteToString(int n)
  9. byteToString(int n)