CommonUtils { @Nonnull public static String extractPackageName(@Nonnull final String fileNameWithoutExtension) { final int lastDot = fileNameWithoutExtension.lastIndexOf('.'); if (lastDot < 0) { return ""; } return fileNameWithoutExtension.substring(0, lastDot).trim(); } private  CommonUtils(); @Nonnull static String ensureEncodingName(@Nullable final String charsetName); @Nonnull static String extractClassName(@Nonnull final String canonicalJavaClassName); @Nonnull static String extractPackageName(@Nonnull final String fileNameWithoutExtension); @Nonnull static File scriptFileToJavaFile(@Nullable final File targetDir, @Nullable final String classPackage, @Nonnull final File scriptFile);  }
@Test public void testExtractPackageName() { assertEquals("", CommonUtils.extractPackageName("")); assertEquals("", CommonUtils.extractPackageName("hello")); assertEquals("a", CommonUtils.extractPackageName("a.hello")); assertEquals("a.b.c", CommonUtils.extractPackageName("a.b.c.hello")); assertEquals("a.b.c", CommonUtils.extractPackageName("a.b.c.")); assertEquals("", CommonUtils.extractPackageName(".hello")); }