@Test public void testRemoveExtension() { Assert.assertEquals("Wrong extension", "/a/b/c.txt", removeExtension("/a/b/c.txt.log")); Assert.assertEquals("Wrong extension", "/a/b/c", removeExtension("/a/b/c.log")); Assert.assertEquals("Wrong extension", "", removeExtension(".txt")); Assert.assertEquals("Wrong extension", ".", removeExtension(".")); Assert.assertEquals("Wrong extension", "a", removeExtension("a.txt")); }
public static String removeExtension(String filename) { if ((filename != null && filename.length() <= 1) || filename == null) { return filename; } LOGGER.debug("Received: {}.", filename); final int idx = filename.lastIndexOf('.'); if (idx >= 0) { filename = filename.substring(0, idx); } LOGGER.debug("Returning: {}.", filename); return filename; }
IOUtils { public static String removeExtension(String filename) { if ((filename != null && filename.length() <= 1) || filename == null) { return filename; } LOGGER.debug("Received: {}.", filename); final int idx = filename.lastIndexOf('.'); if (idx >= 0) { filename = filename.substring(0, idx); } LOGGER.debug("Returning: {}.", filename); return filename; } }
IOUtils { public static String removeExtension(String filename) { if ((filename != null && filename.length() <= 1) || filename == null) { return filename; } LOGGER.debug("Received: {}.", filename); final int idx = filename.lastIndexOf('.'); if (idx >= 0) { filename = filename.substring(0, idx); } LOGGER.debug("Returning: {}.", filename); return filename; }  }
IOUtils { public static String removeExtension(String filename) { if ((filename != null && filename.length() <= 1) || filename == null) { return filename; } LOGGER.debug("Received: {}.", filename); final int idx = filename.lastIndexOf('.'); if (idx >= 0) { filename = filename.substring(0, idx); } LOGGER.debug("Returning: {}.", filename); return filename; }  static Writable findInMapFile(final Text key, URI dirURI, final Configuration conf); @SuppressWarnings("resource") static URI createMapFile(URI inputURI, final Configuration conf); static URI compressFile(final URI uncompressedURI, final String codecName, final Configuration conf); static String addExtension(String filename, final String newExtension, final boolean removeExistingExtension); static String removeExtension(String filename); static URI uncompressFile(final URI archiveURI, final Configuration conf); }
IOUtils { public static String removeExtension(String filename) { if ((filename != null && filename.length() <= 1) || filename == null) { return filename; } LOGGER.debug("Received: {}.", filename); final int idx = filename.lastIndexOf('.'); if (idx >= 0) { filename = filename.substring(0, idx); } LOGGER.debug("Returning: {}.", filename); return filename; }  static Writable findInMapFile(final Text key, URI dirURI, final Configuration conf); @SuppressWarnings("resource") static URI createMapFile(URI inputURI, final Configuration conf); static URI compressFile(final URI uncompressedURI, final String codecName, final Configuration conf); static String addExtension(String filename, final String newExtension, final boolean removeExistingExtension); static String removeExtension(String filename); static URI uncompressFile(final URI archiveURI, final Configuration conf); static final Logger LOGGER; }