Class Util

  • public class Util
    extends Object
    Generic collection of utility methods.
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • getJavaVersion

        public static int getJavaVersion()
        Returns the Java version as an int value.
        the Java version as an int value (8, 9, etc.)
      • readBytes

        public static byte[] readBytes​(InputStream is)
                                throws IOException
        This method consumes an input stream and returns its content, and closes it.
        is - The input stream to read from.
        The bytes read from the stream.
        IOException - Error reading from stream.
      • reverse

        public static <T> T[] reverse​(T[] array)
      • file

        public static File file​(String... pathParts)
      • pathFrom

        public static Path pathFrom​(URL localArtifactUrl)
      • intArrayToList

        public static List<Integer> intArrayToList​(int[] ints)
      • parseInt

        public static int parseInt​(String valueFor)
      • sneakyThrow

        public static <T extends ThrowableRuntimeException sneakyThrow​(Throwable t)
                                                                  throws T extends Throwable
        Re-throw t (even if it's a checked exception) without requiring a throws declaration.

        This function declares a return type of RuntimeException but will never actually return a value. This allows you to use it with a throw statement to convince the compiler that the current branch will not complete.

         throw Util.sneakyThrow(new IOException());

        Adapted from

        T extends Throwable