VirtualFileSystem { public static String stripLast(String path) { if (!(path.startsWith(VirtualFileSystem.separator))) { throw new IllegalArgumentException( "stripLast() needs to be supplied with a full path, i.e, start with \"/\""); } String toReturn = path.substring(0, path.lastIndexOf(separator)); if (toReturn.equals("")) { return "/"; } return toReturn; } private  VirtualFileSystem(); static String getLast(String path); static VirtualFileSystem getVirtualFileSystem(); static String stripLast(String path); static String fixPath(String path); static final String dirName; static final String fileSystemPath; static final String separator; }
@Test public void testStripLast() { assertEquals(VirtualFileSystem.stripLast("/full/path/to/file"), "/full/path/to"); assertEquals(VirtualFileSystem.stripLast("/full/path/to"), "/full/path"); }