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

private static String removeRightBracket(String value) {
    String str = value.trim();/*  w w w  .  ja  v a  2s .c  om*/
    return value.substring(0, str.length() - 1);
}

From source file:Main.java

public static String trimDo(String s) {
    if (s.indexOf(".") > 0) {
        s = s.substring(0, s.indexOf("."));
    }/*from w  ww .j ava  2s.c o  m*/
    return s;
}

From source file:Main.java

/**
 * Gets the tag value without namespace.
 * //from ww  w.j  av a 2  s  .  c o m
 * @param n
 *            the n
 * @return the tag value without namespace
 */
public static String getTagValueWithoutNamespace(Node n) {
    if (n != null) {
        String tag = n.getNodeName();
        return tag.substring(tag.indexOf(":") + 1, tag.length());
    }
    return null;
}

From source file:Main.java

/**
 * for the reason, we use some bit to differ whether it is softap or sta. so, we may get the polluted bssid.
 * /*from  w  w w .j  a va2  s .c  o  m*/
 * softap bssid: 1a:fe:34:77:c0:00 sta bssid: 18:fe:34:77:c0:00
 * 
 * @param BSSID
 * @return the real BSSID(SoftAp's BSSID)
 */
public static String restoreSoftApBSSID(String BSSID) {
    String pollutedBitStr = BSSID.substring(1, 2);
    Integer pollutedBitInt = 0;
    // get pollutedBitInt according to 0x..
    pollutedBitInt = Integer.parseInt(pollutedBitStr, 16);
    Integer cleanBitInt = pollutedBitInt | 0x02;
    String cleanBitStr = Integer.toHexString(cleanBitInt);
    return BSSID.substring(0, 1) + cleanBitStr + BSSID.substring(2);
}

From source file:Main.java

public static String getProtocol(String url) {
    int index = url.indexOf('/');
    return url.substring(0, index + 2);
}

From source file:Main.java

public static float transformPercentToFloat(String formatString) {
    float floatResult = Float.valueOf((formatString.substring(0, formatString.indexOf("%")))) / 100;
    return floatResult;
}

From source file:Main.java

/**
 * change "'aaaa'" to "aaaa"/*from  w w w .  j a va 2 s  .  c  om*/
 * 
 * @param str
 * @return
 */
public static String removeSingleQuote(String str) {
    return str.substring(str.indexOf('\'') + 1, str.lastIndexOf('\''));
}

From source file:Main.java

public static String constructMediaPath(String formFilePath) {
    String pathNoExtension = formFilePath.substring(0, formFilePath.lastIndexOf("."));
    return pathNoExtension + "-media";
}