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

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 float[] getFloatArray(String str) {
    String[] list = str.split(",");
    float[] ar = new float[list.length];
    int i = 0;//from   w  w w  . j a  v  a2 s  .  c  om
    for (String s : list) {
        ar[i++] = Float.parseFloat(s);
    }
    return ar;
}

From source file:Main.java

public static int stringTimeToInt(String time) {
    String[] fields = time.split(":");
    int secs = Integer.parseInt(fields[0]) * 3600 + Integer.parseInt(fields[1]) * 60;
    if (fields.length > 2)
        secs += Integer.parseInt(fields[2]);
    return secs;/*from www .  ja v a 2  s.  com*/
}

From source file:Main.java

public static int ipStringToInt(String ip) {
    String[] arrStrings = ip.split("\\.");
    int r = (Integer.parseInt(arrStrings[0]) << 24) | (Integer.parseInt(arrStrings[1]) << 16)
            | (Integer.parseInt(arrStrings[2]) << 8) | Integer.parseInt(arrStrings[3]);
    return r;/*from   w  ww . j a v  a 2  s  .c  o  m*/
}

From source file:Main.java

public static List<String> devideNum(String numStr) {
    return Arrays.asList(numStr.split("\\" + SPILCT));
}

From source file:Main.java

public static long getTimestamp(String timestamp) {
    return Long.parseLong(timestamp.split(".")[0]);
}

From source file:Main.java

public static String getLastPathComponent(String filePath) {
    String[] segments = filePath.split("/");
    String lastPathComponent = segments[segments.length - 1];
    return lastPathComponent;
}

From source file:Main.java

public static ArrayList<String> toStringArrayList(String str) {
    String[] ar = str.split(",");
    ArrayList<String> ls = new ArrayList<String>();
    for (int i = 0; i < ar.length; i++) {
        if (ar[i] != "")
            ls.add(ar[i]);/*w w w  .j  av a 2 s  .  c  o m*/
    }
    return ls;
}

From source file:Main.java

public static String[] decode(String data) {
    String[] datas = data.split(" ");
    String[] stringDatas = new String[datas.length];
    for (int i = 0; i < datas.length; i++) {
        stringDatas[i] = Integer.toString(Integer.parseInt(datas[i], 16));
    }/* w  ww.  j  a  v a  2 s .  c om*/
    return stringDatas;
}

From source file:Main.java

public static int[] stringToIntArray(String text) {
    String[] parts = text.split("\\s");
    int[] values = new int[parts.length];
    for (int i = 0; i < parts.length; i++) {
        values[i] = Integer.valueOf(parts[i]);
    }/*from ww  w  .ja  va 2  s  .  c o  m*/

    return values;
}