I need to transform
String[] args = {"--path=C:/log", "--time=hourly"};
into
String[] args = {"--path", "C:/log", "--time", "hourly"};
How can I do this in Java 8, in an elegant way?
List<String> newArgs = Lists.newArrayList();
for (String s : args) {
String[] split = s.split("=");
newArgs.add(split[0]);
newArgs.add(split[1]);
}
String[] strarray = new String[newArgs.size()];
return newArgs.toArray(strarray);
String[] result = Stream.of(args)
.flatMap(a -> Stream.of(a.split("=")))
.toArray(String[]::new);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With