@Test public void getFilePathTest() throws IOException { String[] paths = new String[] { Constants.HEADER + "localhost:19998/dir", Constants.HEADER_FT + "localhost:19998/dir", "/dir", "dir" }; String expected = "/dir"; for (String path : paths) { String result = Utils.getFilePath(path); Assert.assertEquals(result, expected); } }
public static String getFilePath(String path) throws IOException { path = validatePath(path); if (path.startsWith(Constants.HEADER)) { path = path.substring(Constants.HEADER.length()); } else if (path.startsWith(Constants.HEADER_FT)) { path = path.substring(Constants.HEADER_FT.length()); } String ret = path.substring(path.indexOf(Constants.PATH_SEPARATOR)); return ret; }
Utils { public static String getFilePath(String path) throws IOException { path = validatePath(path); if (path.startsWith(Constants.HEADER)) { path = path.substring(Constants.HEADER.length()); } else if (path.startsWith(Constants.HEADER_FT)) { path = path.substring(Constants.HEADER_FT.length()); } String ret = path.substring(path.indexOf(Constants.PATH_SEPARATOR)); return ret; } }
Utils { public static String getFilePath(String path) throws IOException { path = validatePath(path); if (path.startsWith(Constants.HEADER)) { path = path.substring(Constants.HEADER.length()); } else if (path.startsWith(Constants.HEADER_FT)) { path = path.substring(Constants.HEADER_FT.length()); } String ret = path.substring(path.indexOf(Constants.PATH_SEPARATOR)); return ret; }  }
Utils { public static String getFilePath(String path) throws IOException { path = validatePath(path); if (path.startsWith(Constants.HEADER)) { path = path.substring(Constants.HEADER.length()); } else if (path.startsWith(Constants.HEADER_FT)) { path = path.substring(Constants.HEADER_FT.length()); } String ret = path.substring(path.indexOf(Constants.PATH_SEPARATOR)); return ret; }  static String getFilePath(String path); static String validatePath(String path); }
Utils { public static String getFilePath(String path) throws IOException { path = validatePath(path); if (path.startsWith(Constants.HEADER)) { path = path.substring(Constants.HEADER.length()); } else if (path.startsWith(Constants.HEADER_FT)) { path = path.substring(Constants.HEADER_FT.length()); } String ret = path.substring(path.indexOf(Constants.PATH_SEPARATOR)); return ret; }  static String getFilePath(String path); static String validatePath(String path);  }