本文整理了Java中org.scijava.util.FileUtils.getPath()
方法的一些代码示例,展示了FileUtils.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getPath()
方法的具体详情如下:
包路径:org.scijava.util.FileUtils
类名称:FileUtils
方法名:getPath
[英]Gets the absolute path to the given file, with the directory separator standardized to forward slash, like most platforms use.
[中]获取给定文件的绝对路径,目录分隔符标准化为正斜杠,就像大多数平台使用的那样。
代码示例来源:origin: scijava/scijava-common
/**
* Gets the absolute path to the given file, with the directory separator
* standardized to forward slash, like most platforms use.
*
* @param file The file whose path will be obtained and standardized.
* @return The file's standardized absolute path.
*/
public static String getPath(final File file) {
final String path = file.getAbsolutePath();
final String slash = System.getProperty("file.separator");
return getPath(path, slash);
}
代码示例来源:origin: org.scijava/scijava-common
/**
* Gets the absolute path to the given file, with the directory separator
* standardized to forward slash, like most platforms use.
*
* @param file The file whose path will be obtained and standardized.
* @return The file's standardized absolute path.
*/
public static String getPath(final File file) {
final String path = file.getAbsolutePath();
final String slash = System.getProperty("file.separator");
return getPath(path, slash);
}
代码示例来源:origin: org.scijava/scijava-common
String path = FileUtils.getPath(classLocation).replace('\\', '/');
代码示例来源:origin: scijava/scijava-common
String path = FileUtils.getPath(classLocation).replace('\\', '/');
代码示例来源:origin: scijava/scijava-common
@Test
public void testGetPath() {
// test that Windows-style paths get standardized
assertEquals("C:/path/to/my-windows-file", FileUtils.getPath(
"C:\\path\\to\\my-windows-file", "\\"));
// test that there are no changes to *nix-style paths
assertEquals("/path/to/my-nix-file", FileUtils.getPath(
"/path/to/my-nix-file", "/"));
// test that an already-standardized path stays good on Windows
assertEquals("/path/to/my-nix-file", FileUtils.getPath(
"/path/to/my-nix-file", "\\"));
}
内容来源于网络,如有侵权,请联系作者删除!