Ejemplo n.º 1
0
  private static File getFile(WebPageContext page) throws IOException {
    String file = page.param(String.class, "file");

    if (file == null) {
      String servletPath = page.param(String.class, "servletPath");

      if (servletPath != null) {
        file = page.getServletContext().getRealPath(servletPath);
      }
    }

    if (file == null) {
      return null;
    }

    File fileInstance = new File(file);

    if (!fileInstance.exists()) {
      IoUtils.createParentDirectories(fileInstance);
    }

    return fileInstance;
  }