Android Char to Int Convert toDigit(char ch, int index)

Here you can find the source of toDigit(char ch, int index)

Description

hex to int

Parameter

Parameter Description
ch a parameter
index a parameter

Exception

Parameter Description
RuntimeException an exception

Return

int

Declaration

protected static int toDigit(char ch, int index) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w w  w. jav  a 2s . c o m
     * hex to int
     *
     * @param ch
     * @param index
     * @return int
     * @throws RuntimeException
     */
    protected static int toDigit(char ch, int index) {
        int digit = Character.digit(ch, 16);
        if (digit == -1) {
            throw new RuntimeException("Illegal hexadecimal character "
                    + ch + " at index " + index);
        }
        return digit;
    }
}