Java Char Create toChar(String delimiter)

Here you can find the source of toChar(String delimiter)

Description

to Char

License

Open Source License

Declaration

public static char toChar(String delimiter) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static char toChar(String delimiter) {
        if (delimiter.length() == 1) {
            return delimiter.charAt(0);
        } else if (delimiter.toLowerCase().startsWith("0x") && delimiter.length() == 4) {
            return (char) Integer.parseInt(delimiter.substring(2), 16);
        } else if (delimiter.toLowerCase().startsWith("\\0") && delimiter.length() == 4) {
            return (char) Integer.parseInt(delimiter.substring(2));
        } else if (Character.isDigit(delimiter.charAt(0))) {
            return (char) Integer.valueOf(delimiter).intValue();
        } else {/*from  w ww.  j a  v a2  s  .  c  o m*/
            throw new IllegalArgumentException("Unrecognized delimiter format:" + delimiter);
        }
    }
}

Related

  1. toChar(int[] arr)
  2. toChar(Object obj)
  3. toChar(Object value)
  4. toChar(short o)
  5. toChar(String chars)
  6. toChar(String parameter)
  7. toChar(String string)
  8. toChar(String string)
  9. toChar(String unicode)