Package civitas.celestis.util
Class IO
java.lang.Object
civitas.celestis.util.IO
Contains input-output utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]Reads an array ofdoubles.static <T> TreadDoubles(String s, Function<double[], T> constructor) Reads an array ofdoubles into an arbitrary typeT.static float[]readFloats(String s) Reads an array offloats.static <T> TreadFloats(String s, Function<float[], T> constructor) Reads an array offloats into an arbitrary typeT.static int[]Reads an array ofints.static <T> TReads an array ofints into an arbitrary typeT.static long[]Reads an array oflongs.static <T> TReads an array oflongs into an arbitrary typeT.
-
Method Details
-
readDoubles
Reads an array ofdoubles.- Parameters:
s- The string representation of the array- Returns:
- The parsed array
- Throws:
NumberFormatException- When the format is invalid
-
readDoubles
@Nonnull public static <T> T readDoubles(@Nonnull String s, @Nonnull Function<double[], T> constructor) throws NumberFormatExceptionReads an array ofdoubles into an arbitrary typeT.- Type Parameters:
T- The type to parse thedoubles into- Parameters:
s- The string representation ofTconstructor- The constructor to use- Returns:
- The parsed
T - Throws:
NumberFormatException- When the format is invalid
-
readFloats
Reads an array offloats.- Parameters:
s- The string representation of the array- Returns:
- The parsed array
- Throws:
NumberFormatException- When the format is invalid
-
readFloats
@Nonnull public static <T> T readFloats(@Nonnull String s, @Nonnull Function<float[], T> constructor) throws NumberFormatExceptionReads an array offloats into an arbitrary typeT.- Type Parameters:
T- The type to parse thefloats into- Parameters:
s- The string representation ofTconstructor- The constructor to use- Returns:
- The parsed
T - Throws:
NumberFormatException- When the format is invalid
-
readLongs
Reads an array oflongs.- Parameters:
s- The string representation of the array- Returns:
- The parsed array
- Throws:
NumberFormatException- When the format is invalid
-
readLongs
@Nonnull public static <T> T readLongs(@Nonnull String s, @Nonnull Function<long[], T> constructor) throws NumberFormatExceptionReads an array oflongs into an arbitrary typeT.- Type Parameters:
T- The type to parse thelongs into- Parameters:
s- The string representation ofTconstructor- The constructor to use- Returns:
- The parsed
T - Throws:
NumberFormatException- When the format is invalid
-
readInts
Reads an array ofints.- Parameters:
s- The string representation of the array- Returns:
- The parsed array
- Throws:
NumberFormatException- When the format is invalid
-
readInts
@Nonnull public static <T> T readInts(@Nonnull String s, @Nonnull Function<int[], T> constructor) throws NumberFormatExceptionReads an array ofints into an arbitrary typeT.- Type Parameters:
T- The type to parse theints into- Parameters:
s- The string representation ofTconstructor- The constructor to use- Returns:
- The parsed
T - Throws:
NumberFormatException- When the format is invalid
-