本文整理了Java中weka.core.Utils.createRelativePath()
方法的一些代码示例,展示了Utils.createRelativePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.createRelativePath()
方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:createRelativePath
[英]Converts a File's absolute path to a path relative to the user (ie start) directory.
[中]将文件的绝对路径转换为相对于用户(ie开始)目录的路径。
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Converts a File's absolute path to a path relative to the user (ie start)
* directory. Includes an additional workaround for Cygwin, which doesn't like
* upper case drive letters.
*
* @param absolute the File to convert to relative path
* @return a File with a path that is relative to the user's directory
* @exception Exception if the path cannot be constructed
*/
public static File convertToRelativePath(File absolute) throws Exception {
File result;
String fileStr;
result = null;
// if we're running windows, it could be Cygwin
if (File.separator.equals("\\")) {
// Cygwin doesn't like upper case drives -> try lower case drive
try {
fileStr = absolute.getPath();
fileStr = fileStr.substring(0, 1).toLowerCase() + fileStr.substring(1);
result = createRelativePath(new File(fileStr));
} catch (Exception e) {
// no luck with Cygwin workaround, convert it like it is
result = createRelativePath(absolute);
}
} else {
result = createRelativePath(absolute);
}
return result;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Converts a File's absolute path to a path relative to the user (ie start)
* directory. Includes an additional workaround for Cygwin, which doesn't like
* upper case drive letters.
*
* @param absolute the File to convert to relative path
* @return a File with a path that is relative to the user's directory
* @exception Exception if the path cannot be constructed
*/
public static File convertToRelativePath(File absolute) throws Exception {
File result;
String fileStr;
result = null;
// if we're running windows, it could be Cygwin
if (File.separator.equals("\\")) {
// Cygwin doesn't like upper case drives -> try lower case drive
try {
fileStr = absolute.getPath();
fileStr = fileStr.substring(0, 1).toLowerCase() + fileStr.substring(1);
result = createRelativePath(new File(fileStr));
} catch (Exception e) {
// no luck with Cygwin workaround, convert it like it is
result = createRelativePath(absolute);
}
} else {
result = createRelativePath(absolute);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!