Example usage for java.lang String substring

List of usage examples for java.lang String substring

Introduction

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

Prototype

public String substring(int beginIndex, int endIndex) 

Source Link

Document

Returns a string that is a substring of this string.

Usage

From source file:Main.java

public static String getName(String url) {
    String a = url.substring(0, url.lastIndexOf("/"));

    return a.substring(a.lastIndexOf("/") + 1) + ".jpg";
}

From source file:Main.java

public static String substring(String s, int start, int length) {
    return s.substring(start, Math.min(start + length, s.length()));
}

From source file:Main.java

/**
 * Convenience method to return the JAXB default for the name of a class/field. 
 * Simply changes the first character to lowercase.
 * @param name The original name// w  ww .  j a  v  a2s . c  om
 * @return The JAXB name
 */
public static String getJAXBDefaultNameForName(String name) {
    return name.substring(0, 1).toLowerCase() + name.substring(1);
}

From source file:Main.java

private static String getFirstLowerVariables(String variables) {
    String firstLetter = variables.substring(0, 1);
    variables = variables.replaceFirst(firstLetter, firstLetter.toLowerCase());
    return variables;
}

From source file:Main.java

public static String capitalize(String s) {
    if (s.length() == 0) {
        return s;
    }/*w  ww.  j  av  a 2 s. c o m*/

    return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
}

From source file:Main.java

/**
 * Uppercase first character//www  . j a v  a 2 s  . c  o m
 *
 * @param str Input string
 * @return Output string
 */
public static String uppercaseFirst(String str) {
    return str.substring(0, 1).toUpperCase(Locale.getDefault()) + str.substring(1, str.length());
}

From source file:Main.java

public static String formattedDouble(double d) {
    String dS = "" + d;
    return dS.length() > 6 ? dS.substring(0, 6) : dS;
}

From source file:Main.java

public static boolean verifyAreaCode(String code) {
    String areaCode = code.substring(0, 2);
    if (areaCodeMap.containsKey(areaCode)) {
        return true;
    } else {//from www .  j a v a 2 s  .  c o m
        return false;
    }
}

From source file:Main.java

@SuppressLint("DefaultLocale")
private static String getColumnName(String mName) {
    String fieldName = mName.substring(4, mName.length());
    String firstLetter = mName.substring(3, 4).toLowerCase();
    fieldName = firstLetter + fieldName;
    return fieldName;
}

From source file:Main.java

public static String get4numberCoded(int i) {
    if (i > 9999 || i < 0) {
        return "";
    }//  w w  w  .  ja va2 s  .  c o  m

    i = i + 10000;
    String s = "" + i;

    return ".." + s.substring(1, 5) + "..";
}