com.twelvemonkeys.io.FileUtil.toFile()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中com.twelvemonkeys.io.FileUtil.toFile()方法的一些代码示例,展示了FileUtil.toFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.toFile()方法的具体详情如下:
包路径:com.twelvemonkeys.io.FileUtil
类名称:FileUtil
方法名:toFile

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");
}

相关文章