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 boolean validNyuEmail(String email) {
    String[] split = email.split("@");
    if (split.length > 1) {
        if (split[1].equals("nyu.edu")) {
            return true;
        } else {/*from   w  w w .  j  ava  2  s.  co  m*/
            return false;
        }
    } else {
        return false;
    }
}

From source file:Main.java

private static String[] vkAuthResponseParse(String url) {
    return url.split("[=#&]");
}

From source file:Main.java

public static int[] getUserSetTime(String s) {
    String[] tmp = s.split(":");
    int[] result = new int[] { 0, 0 };
    for (int i = 0; i < result.length && i < tmp.length; i++) {
        result[i] = Integer.parseInt(tmp[i]);
    }/* www.  ja  v  a 2 s  .  c o m*/
    return result;
}

From source file:Main.java

public static byte[] getByte(String ss) {
    String[] shil = ss.split(" ");
    StringBuilder er = new StringBuilder();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    for (String string : shil) {
        if ("".equals(string)) {
            continue;
        }/*from w ww  . j av  a  2 s  .  com*/
        int i = Integer.valueOf(string, 16);
        out.write(i);
    }
    return out.toByteArray();
}

From source file:Main.java

public static String random(String src) {
    String[] srcList = src.split("");
    List<String> list = Arrays.asList(srcList);
    Collections.shuffle(list);//  w w  w .jav a  2 s  .c om
    StringBuilder result = new StringBuilder();
    for (String i : list) {
        result.append(i);
    }
    return result.toString();
}

From source file:Main.java

/**
 * Check whether the email has username and domain
 *
 * @param aEmailAddress//from   www.  ja v  a2s . co  m
 * @return
 */
private static boolean hasNameAndDomain(String aEmailAddress) {
    String[] tokens = aEmailAddress.split("@");
    return tokens.length == 2 && tokens[0].trim().length() > 0 && tokens[1].trim().length() > 3
            && tokens[1].split("\\.").length > 1 && tokens[1].split("\\.")[1].length() > 1;
}

From source file:Main.java

public static long convertStringDateToLong(String date) {
    String[] splitString = date.split("[^0-9]+");
    int year = Integer.valueOf(splitString[0]);
    int month = Integer.valueOf(splitString[1]) - 1;
    int day = Integer.valueOf(splitString[2]);
    sCalendar.set(year, month, day);/*from w w  w.j a  v a2 s.c  o m*/
    return sCalendar.getTimeInMillis();
}

From source file:Main.java

public static void AddPeers(String peerInfo) {

    for (String peer : peerInfo.split(",")) {
        peers.add(peer);/* w  ww  .  j  a va2  s . c o m*/
    }

}

From source file:Main.java

public static long getBlockTimerMillis(String time) {
    String[] separated = time.split(" ");

    int hours = Integer.parseInt(separated[0].substring(0, separated[0].length() - 1));
    int minutes = Integer.parseInt(separated[1].substring(0, separated[1].length() - 1));
    int seconds = Integer.parseInt(separated[2].substring(0, separated[2].length() - 1));

    long length = (hours * 60 * 60 * 1000) + (minutes * 60 * 1000) + (seconds * 1000);
    long startTime = System.currentTimeMillis();

    return startTime + length;
}

From source file:Main.java

public static String abbreviate(String text) {
    String[] words = text.split("\\s");

    StringBuilder builder = new StringBuilder();
    int i = 0;//from w  ww  .j  a  v a 2  s  . c o  m
    while (i < words.length && builder.length() < 2) {
        String word = words[i].trim();
        if (word.length() > 0)
            builder.append(Character.toUpperCase(word.charAt(0)));
        i++;
    }

    return builder.toString();
}