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

public static String getServerIdFromFullName(String fullName) {
    String[] parts = fullName.split("_");
    if (parts.length > 1) {
        return parts[1];
    }// w  ww  .  j  a  v a 2s. c o  m
    return null;
}

From source file:Main.java

public static int parseDay(String date) {
    String[] time = date.split("-");
    int year = Integer.parseInt(time[0]);
    int month = Integer.parseInt(time[1]);
    int day = Integer.parseInt(time[2]);
    int[] months = { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
    int test = year * 365 + month * months[month] + day;
    return year * 365 + months[month] + day;
}

From source file:Main.java

public static String getDataVerNumber(String url) {
    String[] split = url.split("/");
    if (split.length > 2) {
        return split[split.length - 2];
    }/*from   ww  w  .j a  va2  s . c  o m*/

    return "";
}

From source file:Main.java

public static float[] toFloatArray(String flattened) {
    String[] list = flattened.split(" ");
    float[] points = new float[list.length];
    for (int i = 0; i < list.length; i++)
        points[i] = Float.parseFloat(list[i]);
    return points;
}

From source file:Main.java

private static String format_date_short(String date) {
    String day = date.split("\\/")[0];
    String month = date.split("\\/")[1];
    String year = date.split("\\/")[2];
    if (day.length() == 1)
        day = 0 + day;/*ww  w . j  av a2 s.  co m*/
    if (month.length() == 1)
        month = 0 + month;
    year = year.substring(2);
    return day + "/" + month + "/" + year;
}

From source file:Main.java

public static LinkedHashSet<String> convertStringToSet(String input) {
    String[] array = input.split(",");
    LinkedHashSet<String> list = new LinkedHashSet<>();
    for (int i = 0; i < array.length; i++) {
        list.add(array[i]);/*w  ww  .  ja  v a2  s  .c  o m*/
    }
    return list;
}

From source file:Main.java

public static Calendar dateToCalendar(String date) {
    String[] theDate = date.split(" ");
    Calendar calDate = Calendar.getInstance();
    calDate.set(Integer.parseInt(theDate[0]), Integer.parseInt(theDate[1]) - 1, Integer.parseInt(theDate[2]),
            Integer.parseInt(theDate[3]), Integer.parseInt(theDate[4]), Integer.parseInt(theDate[5]));
    return calDate;
}

From source file:Main.java

public static String getFileExt(String fileName) {
    String[] arr = fileName.split("\\.");
    if (arr.length <= 1) {
        return "";
    } else {/*from   ww w  .j  av  a 2 s  .  co m*/
        return arr[arr.length - 1].toLowerCase();
    }
}

From source file:Main.java

public static String getComponentNormalizedName(String path) {
    String[] subComponents = path.split(PATH_SEPARATOR);
    return subComponents[subComponents.length - 1];
}

From source file:Main.java

public static List<String> stringToGenres(String genres) {
    return Arrays.asList(genres.split(DELIMITER));
}