Example usage for java.lang Character toString

List of usage examples for java.lang Character toString

Introduction

In this page you can find the example usage for java.lang Character toString.

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Character 's value.

Usage

From source file:Main.java

public static void main(String[] argv) {
    Character character1 = new Character('a');
    System.out.println(character1.toString());

}

From source file:Main.java

public static void main(String[] argv) {
    Character character1 = new Character('a');
    Character character2 = new Character('a');
    System.out.println(character1.toString());

    System.out.println(Character.getNumericValue(character2));
}

From source file:CharacterDemo.java

public static void main(String args[]) {
    Character a = new Character('a');
    Character a2 = new Character('a');
    Character b = new Character('b');

    int difference = a.compareTo(b);

    if (difference == 0) {
        System.out.println("a is equal to b.");
    } else if (difference < 0) {
        System.out.println("a is less than b.");
    } else if (difference > 0) {
        System.out.println("a is greater than b.");
    }/*from w  w  w. ja  v a 2  s .  com*/

    System.out.println("a is " + ((a.equals(a2)) ? "equal" : "not equal") + " to a2.");

    System.out.println("The character " + a.toString() + " is "
            + (Character.isUpperCase(a.charValue()) ? "upper" : "lower") + "case.");
}

From source file:MainClass.java

public static String capitalize(String s) throws NullPointerException {
    if (s == null) {
        throw new NullPointerException("Your passed a null argument");
    }//  ww w  .java  2  s .c  o  m
    Character firstChar = s.charAt(0);
    String theRest = s.substring(1);
    return firstChar.toString().toUpperCase() + theRest;
}

From source file:Main.java

public static String getNifLetter(int dni) {
    String nifChars = "TRWAGMYFPDXBNJZSQVHLCKET";
    int module = dni % 23;
    Character nifChar = nifChars.charAt(module);
    return nifChar.toString();
}

From source file:Main.java

public static boolean isGB2312(char c) {
    Character ch = Character.valueOf(c);
    String sCh = ch.toString();
    try {//from   w  ww.java2s. c  om
        byte[] bb = sCh.getBytes("gb2312");
        if (bb.length > 1) {
            return true;
        }
    } catch (java.io.UnsupportedEncodingException ex) {
        return false;
    }
    return false;
}

From source file:Main.java

private static String convertHexToChar(String hexchar) {
    try {/*from w w  w. j  a  v a  2  s .  c  om*/
        int val = Integer.parseInt(hexchar, 16);
        Character charVal = Character.valueOf((char) val);
        return charVal.toString();
    } catch (Exception e) {
    }
    return hexchar;
}

From source file:Main.java

public static boolean isGB2312(char c) {
    Character ch = Character.valueOf(c);
    String sCh = ch.toString();
    try {/*from ww  w.j av a2 s .  c  om*/
        byte[] bb = sCh.getBytes("gb2312");
        if (bb.length > 1) {
            return true;
        }
    } catch (UnsupportedEncodingException ex) {
        return false;
    }
    return false;
}

From source file:Main.java

public static String decode(String entity) {
    if (entity.charAt(entity.length() - 1) == ';') // remove trailing
        // semicolon
        entity = entity.substring(0, entity.length() - 1);
    if (entity.charAt(1) == '#') {
        int start = 2;
        int radix = 10;
        if (entity.charAt(2) == 'X' || entity.charAt(2) == 'x') {
            start++;/* www.j  av  a  2  s  . c o m*/
            radix = 16;
        }
        Character c = new Character((char) Integer.parseInt(entity.substring(start), radix));
        return c.toString();
    } else {
        String s = decoder.get(entity);

        if (s != null)
            return s;
        else
            return "";
    }
}

From source file:org.guvnor.common.services.backend.validation.ValidationUtils.java

public static boolean isFileName(final String value) {
    //Null check//from w  w w  . j a  v a2 s  . c  om
    if (StringUtils.isBlank(value)) {
        return false;
    }

    //Prefix and suffix "." causes issues
    if (value.startsWith(".") || value.endsWith(".")) {
        return false;
    }

    //Illegal character check
    for (Character c : ILLEGAL_CHARACTERS) {
        if (value.contains(c.toString())) {
            return false;
        }
    }

    final File f = new File(value);
    try {
        f.getCanonicalPath();
        return true;
    } catch (IOException e) {
        return false;
    }

}