Java Char Create toChar(String string)

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

Description

to Char

License

Open Source License

Declaration


public static char toChar(String string) 

Method Source Code

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

public class Main {

    public static char toChar(String string) {
        return (char) toInt(string);
    }/* w  w w. j  a  va 2  s .  com*/

    public static int toInt(String value) {
        if (!isBinary(value))
            return 0;

        if (value.length() > 31)
            return Integer.MAX_VALUE;

        return Integer.parseInt(value, 2);
    }

    public static boolean isBinary(String binary) {
        if (binary == null || binary.length() == 0)
            return false;

        for (char c : binary.toCharArray())
            if (!(c == '0' || c == '1'))
                return false;

        return true;
    }
}

Related

  1. toChar(short o)
  2. toChar(String chars)
  3. toChar(String delimiter)
  4. toChar(String parameter)
  5. toChar(String string)
  6. toChar(String unicode)
  7. toCharA(byte[] data)
  8. toCharacter(final String value)
  9. toCharacter(final String value)