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