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) 

Source Link

Document

Returns a string that is a substring of this string.

Usage

From source file:Main.java

/**
 * http://36kr.com/p/5040401.html-->5040401
 * @param pStr//  w w w. ja v  a  2s. c  om
 * @return
 */
public static String getArticleId(String pStr) {
    String tempStr = pStr.substring(pStr.lastIndexOf("/") + 1);
    if (tempStr.contains(".")) {
        String[] temp = tempStr.split("\\."); //  5040196
        return temp[0];
    }
    return pStr;
}

From source file:Main.java

public static String fromIdableName(String xpath) {
    xpath = xpath.substring(1);
    xpath = xpath.replace("-", "/");
    xpath = xpath.replace("_", "[");
    return xpath.replace(":", "]");
}

From source file:Main.java

public static String getDownAudioPath(Context context, String url) {
    String fileName = url.substring(url.lastIndexOf("/") + 1);
    File mediaStorageDir = new File(context.getExternalFilesDir(Environment.DIRECTORY_RINGTONES),
            AudioFolderName);//from  ww w  . j a  va 2s .com

    return mediaStorageDir.getPath() + File.separator + fileName;
}

From source file:Main.java

public static String[] getRackHostName(String hostname) {
    hostname = hostname.substring(1);
    return hostname.split("/");
}

From source file:Main.java

private static String stripPrefix(String name) {
    return name.substring(name.indexOf(":") + 1);
}

From source file:Main.java

public static String getFolder(String s) {
    String path = new File(s).getParent();
    return path.substring(path.lastIndexOf("/") + 1);
}

From source file:Main.java

public static String getSubString(String str, String string) {
    return str.substring(str.indexOf(string));
}

From source file:Main.java

public static String getIp(String str) {
    String ip;/*from  ww w.  j  a v a  2s.c o  m*/
    String s = str.substring(7);
    String[] arrayStr = s.split(":");
    ip = arrayStr[0];
    return ip;
}

From source file:Main.java

public static String decToHex(int dec) {
    String tempString = Integer.toHexString(dec);
    return tempString.substring(2);
}

From source file:Main.java

public static String formatCardEndFour(String cardNo) {
    String card = "";
    card += cardNo.substring(cardNo.length() - 4);
    return card;/*  w w  w  . j  a  v  a 2  s  .co  m*/
}