/**
* @author lautturi.com
* Java example: split a string by period delimiter in java
*/
import java.util.*;
import java.util.regex.Pattern;
public class Lautturi {
public static void main(String[] args) {
String str = "hello world. hi lautturi. welcome";
//String[] arr = str.split("\\.");
// Or using Pattern
String[] arr = str.split(Pattern.quote("."));
System.out.println(Arrays.toString(arr));
for (String s : arr)
System.out.println(s);
}
}
output:
[hello world, hi lautturi, welcome] hello world hi lautturi welcome