Example usage for java.lang String split

List of usage examples for java.lang String split

Introduction

In this page you can find the example usage for java.lang String split.

Prototype

public String[] split(String regex) 

Source Link

Document

Splits this string around matches of the given regular expression.

Usage

From source file:Main.java

/**
 * StringSplit//from  w  ww  .  ja  v a  2 s  . c o  m
 */
public static String[] stringSplit(String string, String splitCharacter) {
    return string.split(splitCharacter);

}

From source file:Main.java

public static Integer getColorFromRgb(String rgb) {
    String[] rgbArray = rgb.split("\\s+");
    return Color.rgb(Integer.valueOf(rgbArray[0]), Integer.valueOf(rgbArray[1]), Integer.valueOf(rgbArray[2]));
}

From source file:Main.java

static String getLastPathElement(String relativePath) {
    String[] pathComponents = relativePath.split("/");
    if (pathComponents.length == 0)
        return null;
    return pathComponents[pathComponents.length - 1];
}

From source file:Main.java

public static Map<String, Integer> countOccurencesOfWords(String str) {
    String[] words = str.split(("[\\p{IsPunctuation}\\p{IsWhite_Space}]+"));
    Map<String, Integer> map = new HashMap<String, Integer>();
    for (String s : words) {
        System.out.println(s);/*  www  . j  a  va 2  s .  c  o  m*/
        if (map.containsKey(s)) {
            map.put(s, map.get(s) + 1);
        } else {
            map.put(s, 1);
        }
    }
    return map;
}

From source file:Main.java

/**
 * permet de recuperer la dernier chaine du un chemin
 *   EXP sdcard/loca/s0/Documentation temporaire/S31/  => Donnera "S31"
 * @param path//from ww w  .  j  a  va2 s  .co  m
 * @return
 */
public static String getLastOfPath(String path) {
    String[] names = path.split("/");
    return names[names.length - 1];
}

From source file:Main.java

private static List<String> splitOne(String wordString) {
    return Arrays.asList(wordString.split("#"));
}

From source file:Main.java

/**
 * parse bssid/*  w  ww .  ja v a 2  s  .  co m*/
 * 
 * @param bssid the bssid
 * @return byte converted from bssid
 */
public static byte[] parseBssid2bytes(String bssid) {
    String bssidSplits[] = bssid.split(":");
    byte[] result = new byte[bssidSplits.length];
    for (int i = 0; i < bssidSplits.length; i++) {
        result[i] = (byte) Integer.parseInt(bssidSplits[i], 16);
    }
    return result;
}

From source file:Main.java

public static String getFieldString(String fields) {
    String[] fieldArr = fields.split("[,]");
    StringBuilder result = new StringBuilder();

    for (int i = 0, len = fieldArr.length; i < len; i++) {
        if (i > 0) {
            result.append("&");
        }/*w w w  . j  a v a  2 s  . com*/
        result.append("fields=").append(fieldArr[i]);
    }

    return result.toString();
}

From source file:Main.java

public static String chopQName(String text, String qName) {
    String[] tokens = text.split(qName);
    if (tokens != null && tokens.length >= 1) {
        text = tokens[tokens.length - 1];
    }//from  ww  w  .  j av a 2 s  .c o m

    return text;
}

From source file:Main.java

/**
 * Extract the firmware version information from the file name.
 *
 * @param fileName is the full name including extension.
 * @return file name without the extension.
 *//*from w  w  w  .j a  va 2  s . c o  m*/
public static String extractVersionName(String fileName) {
    String[] versionNameArr = fileName.split("\\.");

    return versionNameArr[0];
}