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 int getIntager(String str) {
    str = str.substring(0, str.length() - 2);
    int ab = Integer.parseInt(str);
    return ab;/*from  w ww.j a  v  a2  s  .  c  o m*/
}

From source file:Main.java

public static String capitalize(String string) {
    return string.substring(0, 1).toUpperCase() + string.substring(1);
}

From source file:Main.java

public static String mobileByPasswd(String mobile) {
    return mobile.substring(0, 3) + " **** " + mobile.substring(7, 11);
}

From source file:Main.java

public static String dateFormat(String date) {
    return date.substring(0, 10);
}

From source file:Main.java

public static String mobile4(String phone2) {
    return phone2.substring(0, 3) + "****" + phone2.substring(7, phone2.length());
}

From source file:Main.java

public static String getFilename(String urlpath) {
    return urlpath.substring(urlpath.lastIndexOf("/") + 1, urlpath.length());
}

From source file:Main.java

public static String getFileName(String url) {
    return url.substring(url.lastIndexOf(File.separator) + 1, url.lastIndexOf("."));
}

From source file:Main.java

public static String getNickname(String account) {
    return account.substring(0, account.indexOf("@"));
}

From source file:Main.java

/**
 * Gets the episode number in string format for the given episode string
 * @param ep Episode string e.g. s01e04//from w  w  w . j a  va 2  s. c o m
 * @return String episode number e.g. "04"
 */
public static String getEpisodeNo(String ep) {
    return ep.substring(4, 6);
}

From source file:Main.java

public static String getFirstCharacter(String name) {

    return (name.substring(0, 1));
}