1String string = "004-034556";
2String[] parts = string.split("-");
3String part1 = parts[0]; // 004
4String part2 = parts[1]; // 034556
5
1public class SplitExample2 {
2 public static void main(String args[])
3 {
4 String str = "My name is Chaitanya";
5 //regular expression is a whitespace here
6 String[] arr = str.split(" ");
7
8 for (String s : arr)
9 System.out.println(s);
10 }
11}
1String textfile = "ReadMe.txt";
2String filename = textfile.split(".")[0];
3String extension = textfile.split(".")[1];
1String textfile = "ReadMe.txt";
2String filename = textfile.split("\\.")[0];
3String extension = textfile.split("\\.")[1];