Example usage for java.lang String charAt

List of usage examples for java.lang String charAt

Introduction

In this page you can find the example usage for java.lang String charAt.

Prototype

public char charAt(int index) 

Source Link

Document

Returns the char value at the specified index.

Usage

From source file:Main.java

public static String convertVertical(String str) {
    StringBuilder sp = new StringBuilder();
    for (int i = 0; i < str.length(); i++) {
        sp.append(str.charAt(i));
        sp.append('\n');
    }//  ww w.  j  ava  2s  .  c  om
    return sp.toString();
}

From source file:Main.java

public static boolean isJustDigitStar1(String str) {
    int len = 0;// www  .jav  a2s .  c o m
    for (int idx = 0; idx < str.length(); idx++) {
        if (Character.isDigit(str.charAt(idx)) || str.charAt(idx) == '*' || str.charAt(idx) == '-') {
            len++;
        }
    }
    if (len == str.length()) {
        return true;
    }
    return false;
}

From source file:Main.java

public static boolean isAlphaNumericString(String s) {
    boolean b = true;
    for (int i = 0; i < s.length(); i++) {
        if (!isAlphaNumeric(s.charAt(i))) {
            b = false;/*  w w w  . j  a  v a 2  s.c o  m*/
            break;
        }
    }
    return b;
}

From source file:Main.java

public static String getURL(String v) {

    int site = v.indexOf("http://");
    if (site >= 0) {
        int end = v.length();
        String chars = " \n\r\t";
        for (int c = 0; c < chars.length(); c++) {
            int r = v.indexOf(chars.charAt(c), site);
            if (r >= 0 && r < end) {
                end = r;/*from ww  w .j  a v a 2  s  . c o  m*/
            }
        }
        return v.substring(site, end);
    }
    return null;

}

From source file:Main.java

public static int JSHash(String str) {
    int hash = 1315423911;

    for (int i = 0; i < str.length(); i++) {
        hash ^= ((hash << 5) + str.charAt(i) + (hash >> 2));
    }/*w  ww.j  a  va2 s  .  co  m*/

    return (hash & 0x7FFFFFFF);
}

From source file:Main.java

public static boolean isJustDigitStar(String str) {
    int len = 0;/*from   w  w  w  . j a  v  a  2  s . c om*/
    for (int idx = 0; idx < str.length(); idx++) {
        if (Character.isDigit(str.charAt(idx)) || str.charAt(idx) == '.') {
            len++;
        }
    }
    if (len == str.length()) {
        return true;
    }
    return false;
}

From source file:Main.java

public static int indexOfAny(String findIn, String findAnyChar, int startPos) {
    for (int i = 0; i < findAnyChar.length(); i++) {
        char c = findAnyChar.charAt(i);
        int pos = findIn.indexOf(c, startPos);
        if (pos >= 0) {
            return pos;
        }//from  w ww. j a  v  a2 s .c o  m
    }
    return -1;
}

From source file:Main.java

public static String capitalize(String s) {
    if (TextUtils.isEmpty(s)) {
        return "";
    }//  ww  w.  j a v a  2s.  c o  m
    final char first = s.charAt(0);
    if (Character.isUpperCase(first)) {
        return s;
    } else {
        return Character.toUpperCase(first) + s.substring(1);
    }
}

From source file:Main.java

private static boolean isEnglishNumberLegal(String number) {
    for (int i = 0; i < number.length(); i++)
        if (!ENGLISH_TO_PERSIAN.containsKey(number.charAt(i)))
            return false;
    return true;// w w w .j  av  a 2  s.  co m
}

From source file:Main.java

public static int DJBHash(String str) {
    int hash = 5381;

    for (int i = 0; i < str.length(); i++) {
        hash = ((hash << 5) + hash) + str.charAt(i);
    }//from   w ww . j av  a  2 s  . com

    return (hash & 0x7FFFFFFF);
}