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 boolean isXML(String cType) {
    String parts[] = cType.split(";");

    return ((parts[0].equals("text/xml") || parts[0].equals("application/xml")));
}

From source file:Main.java

public static String getFirstImg(String imgUrl) {
    String img[] = imgUrl.split(splitString);
    return img[0];
}

From source file:Main.java

public static float[] toFloatList(String str) {
    String[] strs = str.split(",");
    float[] floats = new float[strs.length];
    for (int i = 0; i < strs.length; i++)
        floats[i] = Float.valueOf(strs[i]);
    return floats;
}

From source file:Main.java

public static int parseMonth(String date) {
    String[] time = date.split("-");
    int year = Integer.parseInt(time[0]);
    int month = Integer.parseInt(time[1]);
    return year * 12 + month + 1;
}

From source file:Main.java

public static String getBlockPrefixByCdataName(String name) {
    String[] strs = name.split("_");
    if (strs == null || strs.length != 4) {
        return null;
    }//from www. j  a v  a 2 s  .  com
    return "blk_" + strs[1];
}

From source file:Main.java

public static String convertToAge(String age) {
    String[] dates = age.split("-");
    int year = Integer.parseInt(dates[0]);
    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    return (currentYear - year) + "";
}

From source file:Main.java

public static String[] parseStrArrayInString(String str, String divider) {

    return str.split(divider);
}

From source file:Main.java

public static String getFileSuffix(String path) {
    String[] arg = path.split("\\.");
    if (arg.length > 1) {
        return (arg[arg.length - 1]);
    } else {/*w  ww.j ava 2s  . c  om*/
        return null;
    }
}

From source file:Main.java

public static int getUserIdFromQRText(String QRText) {
    String[] Params = QRText.split(PARAM_SEP);
    return Integer.parseInt(Params[USER_ID_INDEX].split(VALUE_SEP)[1]);
}

From source file:Main.java

public static long parseJsonDate(String jsonDate) {
    String[] result = jsonDate.split("[(]");
    String[] resultTwo = result[1].split("[+]");
    return Long.parseLong(resultTwo[0]);
}