import java.util.*;import java.util.stream.*; class Ideone { public static void main (String[] args) { String in = "useful1.useless1,useful2.useless2,useful3.useless3,"; String[] strArray = in.split(","); char[][] usefulChars = Arrays.stream(strArray) .map(s -> s.replaceAll("\\..*", "")) .map(String::toCharArray) .toArray(char[][]::new); System.out.println(Arrays.deepToString(usefulChars)); }}
Standard input is empty
[[u, s, e, f, u, l, 1], [u, s, e, f, u, l, 2], [u, s, e, f, u, l, 3]]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!