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 void main(String[] args) throws Exception {
    // map//w  ww .ja v  a2  s . c o  m
    List<String> words = Arrays.asList("Hello", "World");

    words.stream().flatMap((String line) -> Arrays.stream(line.split(""))).distinct()
            .forEach(System.out::println);

}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s = "";
    String[] words = s.split("");
    for (String string : words) {
        System.out.println(">" + string + "<");
    }/*from   w ww .  j  a  v  a 2s.  c o  m*/
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s = " ";
    String[] words = s.split(" ");
    for (String string : words) {
        System.out.println(">" + string + "<");
    }//from  w  w  w.  j a  va2 s .co m
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s = "     ";
    String[] words = s.split(" ");

    for (String string : words) {
        System.out.println(">" + string + "<");
    }//from  w w w.  jav a 2 s.co m
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s = "  s";
    String[] words = s.split(" ");
    for (String string : words) {
        System.out.println(">" + string + "<");
    }//from   w  w w .  java  2 s .  c o  m
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s = "A|BB|CCC";

    String[] words = s.split("\\|");
    for (String str : words) {
        System.out.println(str);//w  w w.  j  a v  a2 s.  com
    }
}

From source file:Main.java

public static void main(String[] args) {
    String word = "abc|def";
    String[] splitted = word.split("\\|");
    System.out.println(Arrays.toString(splitted)); /* prints: [abc, def] */
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s = "   a  ";
    String[] words = s.split(" ");
    for (String string : words) {
        System.out.println(">" + string + "<");
    }//from   www .ja v  a 2  s  . c o  m
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String s3 = "A  B C";
    String[] words = s3.split(" ");
    for (String s : words) {
        System.out.println(s);//from  w  w  w  .j av a  2  s  . c o  m
    }
}

From source file:Main.java

public static void main(String[] arguments) {
    String input = "12%12%%12";

    String[] piece = input.split("[-/%]");
    for (int j = 0; j < piece.length; j++)
        System.out.println(piece[j] + "\t");
}