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

/**
 * Capitalizes the first letter of the given string.
 * /* ww w .j  av  a2  s  .c  om*/
 * @param text the string to capitalize.
 * 
 * @return the modified string.
 */
public static String capitalize(String text) {
    String h = text.substring(0, 1).toUpperCase();
    String t = text.substring(1);
    return h + t;
}

From source file:Main.java

public static String getGPSFileName(String pictureFileName) {
    String gpsFileName = pictureFileName.substring(0, pictureFileName.length() - ".jpg".length()) + ".gs";
    return gpsFileName;
}

From source file:Main.java

/**
 * by Jesse Gallegher/*from   ww  w  .  j  a va2 s.  c o  m*/
 * 
 */

public static String strLeft(String input, String delimiter) {
    return input.substring(0, input.indexOf(delimiter));
}

From source file:Main.java

static String toClassName(final String type) {
    return type.substring(1, type.length() - 1);
}

From source file:Main.java

public static String stripDashes(UUID inputUuid) {
    String input = inputUuid.toString();
    return input.substring(0, 8) + input.substring(9, 13) + input.substring(14, 18) + input.substring(19, 23)
            + input.substring(24, 36);/*from w w  w . ja  v  a  2s  . c  o m*/
}

From source file:Main.java

/**
 * <p>/*from  w  w w .  j  a  v a  2s . c o  m*/
 * Capitalize the first letter but leave the rest as they are.
 * </p>
        
 *
 * @param data capitalize this
 * @return String
 */
static public String capitalizeFirstLetter(String data) {
    String firstLetter = data.substring(0, 1).toUpperCase();
    String restLetters = data.substring(1);
    return firstLetter + restLetters;
}

From source file:Main.java

public static int extractTag(String whole, String tag) {
    return Integer.parseInt(whole.substring(tag.length(), whole.length()));
}

From source file:Main.java

/**
 * judge whether is a pdf file./*from  ww w  . ja v a  2s. c om*/
 * 
 * @param path the file path
 * @return true if it is a image file, otherwise false
 */
public static boolean isPdfFile(String path) {

    String extention = path.substring(path.lastIndexOf(".", path.length()) + 1, path.length());
    if (extention.equalsIgnoreCase("pdf")) {
        return true;
    }
    return false;
}

From source file:Main.java

/**
 * Removes last character of String parameter and returns it back
 * @param stringToTrimLastCharacterOf/*  ww w . j a  v a  2 s  .com*/
 * @return
 */
public static String sansLastCharacterOfString(String stringToTrimLastCharacterOf) {
    return stringToTrimLastCharacterOf.substring(0, stringToTrimLastCharacterOf.length() - 1);
}

From source file:Main.java

public static String getNodeIdShort(String nodeId) {
    return nodeId == null ? "<null>" : nodeId.substring(0, 8);
}