本文整理了Java中com.twelvemonkeys.io.FileUtil.toFile()
方法的一些代码示例,展示了FileUtil.toFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.toFile()
方法的具体详情如下:
包路径:com.twelvemonkeys.io.FileUtil
类名称:FileUtil
方法名:toFile
[英]Creates a File based on the path part of the URL, for file-protocol ( file:) based URLs.
[中]基于URL的路径部分为基于文件协议(File:)的URL创建文件。
代码示例来源:origin: haraldk/TwelveMonkeys
public static void main(String[] pArgs) throws IOException {
File file;
if (pArgs[0].startsWith("file:")) {
file = toFile(new URL(pArgs[0]));
System.out.println(file);
}
else {
file = new File(pArgs[0]);
System.out.println(file.toURL());
}
System.out.println("Free space: " + getFreeSpace(file) + "/" + getTotalSpace(file) + " bytes");
}
代码示例来源:origin: haraldk/TwelveMonkeys
/**
* This method is called by the server before the filter goes into service,
* and here it determines the file upload directory.
*
* @throws ServletException
*/
public void init() throws ServletException {
// Get the name of the upload directory.
String uploadDirParam = getInitParameter("uploadDir");
if (!StringUtil.isEmpty(uploadDirParam)) {
try {
URL uploadDirURL = getServletContext().getResource(uploadDirParam);
uploadDir = FileUtil.toFile(uploadDirURL);
}
catch (MalformedURLException e) {
throw new ServletException(e.getMessage(), e);
}
}
if (uploadDir == null) {
uploadDir = ServletUtil.getTempDir(getServletContext());
}
}
代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.common/common-io
public static void main(String[] pArgs) throws IOException {
File file;
if (pArgs[0].startsWith("file:")) {
file = toFile(new URL(pArgs[0]));
System.out.println(file);
}
else {
file = new File(pArgs[0]);
System.out.println(file.toURL());
}
System.out.println("Free space: " + getFreeSpace(file) + "/" + getTotalSpace(file) + " bytes");
}
代码示例来源:origin: com.twelvemonkeys/twelvemonkeys-core
public static void main(String[] pArgs) throws IOException {
File file;
if (pArgs[0].startsWith("file:")) {
file = toFile(new URL(pArgs[0]));
System.out.println(file);
}
else {
file = new File(pArgs[0]);
System.out.println(file.toURL());
}
System.out.println("Free space: " + getFreeSpace(file) + "/" + getTotalSpace(file) + " bytes");
}
内容来源于网络,如有侵权,请联系作者删除!