dan*_*cek 11
只java.io.File使用最简单的方法是:
String combined_path = new File("test/", "/go").getPath();
Run Code Online (Sandbox Code Playgroud)
FilenameUtils.normalize()来自Apache Commons IO做你想要的.
例:
FilenameUtils.normalize("foo/" + "/bar");
Run Code Online (Sandbox Code Playgroud)
返回字符串 "foo/bar"
public static String combine (String path1, String path2)
{
File file1 = new File(path1);
File file2 = new File(file1, path2);
return file2.getPath();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6931 次 |
| 最近记录: |