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

/**
 * judge whether is a pdz file./*w w  w .ja  v a  2  s .com*/
 * 
 * @param path the file path
 * @return true if it is a image file, otherwise false
 */
public static boolean isTemplateFile(String path) {

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

From source file:Main.java

public static String getJoinedSysDateTime() {
    String str = getSysDateTime();
    str = str.substring(0, 4) + str.substring(5, 7) + str.substring(8, 10) + str.substring(11, 13)
            + str.substring(14, 16) + str.substring(17, 19);
    return str;/*from  w  ww  .j a  v a2s. co  m*/
}

From source file:Main.java

/**
 * /*from  w  w  w.  j av  a  2 s.c  o m*/
 *  Makes the first letter caps and the rest lowercase.
 * 
 *
 * 
 *  For example <code>fooBar</code> becomes <code>Foobar</code>.
 * 
 *
 * @param data capitalize this
 * @return String
 */
static public String firstLetterCaps(String data) {
    String firstLetter = data.substring(0, 1).toUpperCase();
    String restLetters = data.substring(1).toLowerCase();
    return firstLetter + restLetters;
}

From source file:Main.java

/**
 * /*from   w  w w  .ja va  2s.c o  m*/
 * @param input
 * @return
 */
public static int fourToTime(String input) {
    int min = Integer.parseInt(input.substring(0, 2));
    int sec = Integer.parseInt(input.substring(2, 4));
    return min * 60 + sec;
}

From source file:Main.java

public static String capitalizeFirstLetter(String s) {
    String result = "";
    result = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
    return result;
}

From source file:Main.java

public static String cutLastChar(String str) {
    return (isEmpty(str)) ? str : str.substring(0, str.length() - 1);
}

From source file:Main.java

private static String getRegLineValue(String regLine) {
    String regLineValue = regLine.split("=")[1];
    return regLineValue.substring(1, regLineValue.length() - 1);
}

From source file:Main.java

public static String getMNC(String IMSI) {

    String IMSIsub = IMSI.substring(3, 5);
    if (IMSIsub.equals("01")) {
        return "CHINA_UNICOM";
    } else if (IMSIsub.equals("00")) {
        return "CHINA_MOBILE";
    } else if (IMSIsub.equals("03")) {
        return "CHINA_TELECOM";
    } else {//from  w  ww .  j a  v a2s.c om
        return null;
    }
}

From source file:Main.java

/**
 * from "myFunction(arg1,arg2)", return ["arg1","arg2"]
 *///  ww  w.j a  v  a2  s .c o  m
public static String[] getAttributes(String tag) {
    String attributes = tag.substring(tag.indexOf('(') + 1, tag.lastIndexOf(')'));
    if (attributes.isEmpty())
        return new String[0];
    return trim(attributes.split(","));
}

From source file:Main.java

/**
 * Sets the first character to UpperCase.
 *
 * @param name//w  ww. j av  a 2s.c o m
 *            String to be modified.
 * @return Modified string.
 */
public static String refactorOpsName(String name) {
    return name.substring(0, 1).toUpperCase() + name.substring(1);

}