Simplify the parseInts method

master
jvoisin 5 years ago
parent 29b083ddac
commit 332718386b
  1. 10
      airsonic-main/src/main/java/org/airsonic/player/util/StringUtil.java

@ -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;
} }
/** /**

Loading…
Cancel
Save