Simplify the parseInts method
This commit is contained in:
@@ -33,6 +33,7 @@ import java.text.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Miscellaneous string utility methods.
|
* Miscellaneous string utility methods.
|
||||||
@@ -249,12 +250,9 @@ public final class StringUtil {
|
|||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] strings = StringUtils.split(s);
|
return Stream.of(StringUtils.split(s))
|
||||||
int[] ints = new int[strings.length];
|
.mapToInt(Integer::parseInt)
|
||||||
for (int i = 0; i < strings.length; i++) {
|
.toArray();
|
||||||
ints[i] = Integer.parseInt(strings[i]);
|
|
||||||
}
|
|
||||||
return ints;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user