@Test public void testCanTellThatExtensionIsMissingWhenAPathContainsDots() { assertNull(FileTools.getExtension("/a/path.with.dots/foo")); }
public static String getExtension(String name) { final int dot = name.lastIndexOf('.'); final int slash = name.lastIndexOf('/'); if(dot != -1) { return slash != -1 && slash > dot ? null : name.substring(dot+1); } else { return null; } }
FileTools { public static String getExtension(String name) { final int dot = name.lastIndexOf('.'); final int slash = name.lastIndexOf('/'); if(dot != -1) { return slash != -1 && slash > dot ? null : name.substring(dot+1); } else { return null; } } }
FileTools { public static String getExtension(String name) { final int dot = name.lastIndexOf('.'); final int slash = name.lastIndexOf('/'); if(dot != -1) { return slash != -1 && slash > dot ? null : name.substring(dot+1); } else { return null; } }  }
FileTools { public static String getExtension(String name) { final int dot = name.lastIndexOf('.'); final int slash = name.lastIndexOf('/'); if(dot != -1) { return slash != -1 && slash > dot ? null : name.substring(dot+1); } else { return null; } }  static String replaceIllegalCharacters(String name, String replacement); static URL asUrl(String url); static String getExtension(String name); static String getParent(File file); }
FileTools { public static String getExtension(String name) { final int dot = name.lastIndexOf('.'); final int slash = name.lastIndexOf('/'); if(dot != -1) { return slash != -1 && slash > dot ? null : name.substring(dot+1); } else { return null; } }  static String replaceIllegalCharacters(String name, String replacement); static URL asUrl(String url); static String getExtension(String name); static String getParent(File file);  }