Utils { public static long parseMemString(final String strMemSize) { if (strMemSize == null) { return 0L; } final long size; if (strMemSize.endsWith("g") || strMemSize.endsWith("G") || strMemSize.endsWith("m") || strMemSize.endsWith("M") || strMemSize.endsWith("k") || strMemSize.endsWith("K")) { final String strSize = strMemSize.substring(0, strMemSize.length() - 1); size = Long.parseLong(strSize); } else { size = Long.parseLong(strMemSize); } final long sizeInKb; if (strMemSize.endsWith("g") || strMemSize.endsWith("G")) { sizeInKb = size * 1024L * 1024L; } else if (strMemSize.endsWith("m") || strMemSize.endsWith("M")) { sizeInKb = size * 1024L; } else if (strMemSize.endsWith("k") || strMemSize.endsWith("K")) { sizeInKb = size; } else { sizeInKb = size / 1024L; } return sizeInKb; } private  Utils(); static boolean equals(final Object a, final Object b); static T nonNull(final T t); static File findFilefromDir(final File dir, final String fn); static T ifNull(final T value, final T defaultValue); static void croak(final String message, final int exitCode); static boolean isValidPort(final int port); static File createTempDir(); static File createTempDir(final File parent); static void zip(final File input, final File output); static void zipFolderContent(final File folder, final File output); static void unzip(final ZipFile source, final File dest); static String flattenToString(final Collection<?> collection,
      final String delimiter); static Double convertToDouble(final Object obj); static Object callConstructor(final Class<?> cls, final Object... args); static Object invokeStaticMethod(final ClassLoader loader, final String className,
      final String methodName, final Object... args); static void copyStream(final InputStream input, final OutputStream output); static long parseMemString(final String strMemSize); static CronExpression parseCronExpression(final String cronExpression,
      final DateTimeZone timezone); static boolean isCronExpressionValid(final String cronExpression,
      final DateTimeZone timezone); static ArrayList<String> runProcess(String... commands); static void mergeTypeClassPaths(
      List<String> destinationPaths, final List<String> sourcePaths, final String rootPath); static void mergeStringList(
      final List<String> destinationList, final List<String> sourceList);  }
@Test public void testMemoryStringConversion() { Assert.assertEquals(Utils.parseMemString("1024"), 1L); Assert.assertEquals(Utils.parseMemString("1K"), 1L); Assert.assertEquals(Utils.parseMemString("1M"), 1024L); Assert.assertEquals(Utils.parseMemString("1G"), 1024L * 1024L); Assert.assertEquals(Utils.parseMemString("1k"), 1L); Assert.assertEquals(Utils.parseMemString("1m"), 1024L); Assert.assertEquals(Utils.parseMemString("1g"), 1024L * 1024L); Assert.assertEquals(Utils.parseMemString("5000"), 4L); Assert.assertEquals(Utils.parseMemString("1024K"), 1024L); Assert.assertEquals(Utils.parseMemString("512M"), 512 * 1024L); Assert.assertEquals(Utils.parseMemString("2G"), 2L * 1024L * 1024L); }