Here you can find the source of convertHexToInt(String hex)
public static int convertHexToInt(String hex)
//package com.java2s; /*/*from w ww .j av a 2 s . c o m*/ * File: UtilitiesCollection.java * Project: MPI Linguistic Application * Date: 07 February 2007 * * Copyright (C) 2001-2007 Max Planck Institute for Psycholinguistics * * This program 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 2 of the License, or * (at your option) any later version. * * 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 * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { /** Wandle 4-stellige Hexadezimalkodierung in Nummer um (z.B. 000a -> 10) */ public static int convertHexToInt(String hex) { hex = hex.toLowerCase(); char[] chex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; int[] c = { 0, 0, 0, 0 }; for (int j = 0; j < 4; j++) { for (int i = 0; i < 16; i++) { if (hex.charAt(j) == chex[i]) { c[j] = i; } } } int no = (c[3] + (16 * c[2]) + (16 * 16 * c[1]) + (16 * 16 * 16 * c[0])); return no; } }