Here you can find the source of rgbToHex(int r, int g, int b)
public static String rgbToHex(int r, int g, int b)
//package com.java2s; //License from project: Open Source License public class Main { public static String rgbToHex(int r, int g, int b) { String sr = Integer.toHexString(r); String sg = Integer.toHexString(g); String sb = Integer.toHexString(b); if (sr.length() < 2) sr = "0" + sr; if (sg.length() < 2) sg = "0" + sg; if (sb.length() < 2) sb = "0" + sb; return "#" + sr + sg + sb; }//from w ww . j a v a2s. c o m }