Here you can find the source of toHexaString(int value)
public static String toHexaString(int value)
//package com.java2s; /*/*www . j av a 2s . c om*/ * Copyright 2010, 2011 Institut Pasteur. * * This file is part of ICY. * * ICY is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ICY 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICY. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Returns a string representation of the integer argument as an * unsigned integer in base 16. */ public static String toHexaString(int value) { return Integer.toHexString(value); } /** * Returns a string representation of the integer argument as an * unsigned integer in base 16.<br> * Force the returned string to have the specified size :<br> * If the string is longer then only last past is kept.<br> * If the string is shorter then leading 0 are added to the string. */ public static String toHexaString(int value, int size) { String result = Integer.toHexString(value); if (result.length() > size) return result.substring(result.length() - size); while (result.length() < size) result = "0" + result; return result; } }