通过多层目录参数创建文件<br>
此方法会检查slip漏洞，漏洞说明见http://blog.nsfocus.net/zip-slip-2/

@param directory 父目录
@param names 元素名（多层目录名）
@return the file 文件
@since 4.0.6
174421
public static File file(File directory, String... names) {
		Assert.notNull(directory, "directorydirectory must not be null");
		if (ArrayUtil.isEmpty(names)) {
			return directory;
		}

		File file = directory;
		for (String name : names) {
			if (null != name) {
				file = file(file, name);
			}
		}
		return file;
	}
876140
public static void mkdirs(File directory) throws CreateDirectoryException {
    if (directory.exists()) {
      // file exists and *is* a directory
      if (directory.isDirectory()) {
        return;
      }

      // file exists, but is not a directory - delete it
      if (!directory.delete()) {
        throw new CreateDirectoryException(
            directory.getAbsolutePath(),
            new FileDeleteException(directory.getAbsolutePath()));
      }
    }

    // doesn't exist. Create one
    if (!directory.mkdirs() && !directory.isDirectory()) {
      throw new CreateDirectoryException(directory.getAbsolutePath());
    }
  }
1004666
public static void zip(File[] sources, File target, String compressFileName) throws IOException {
		$.notEmpty(sources);
		$.notNull(target);
		if (!target.isDirectory()) {
			throw new IllegalArgumentException("The target can be a directory");
		}
		// 压缩后文件的名称
		compressFileName = $.notEmpty(compressFileName) ? compressFileName : sources[0].getName() + ".zip";
		FileOutputStream fileOut = new FileOutputStream(target.getAbsolutePath() + File.separator + compressFileName);
		ZipArchiveOutputStream zipOut = new ZipArchiveOutputStream(fileOut);
		for (int i = 0; i < sources.length; i++) {
			compress(sources[i], zipOut, null);
		}
		zipOut.close();
	}
243202
public YokeFileUpload getFile(@NotNull final String name) {
        if (files == null) {
            return null;
        }

        return files.get(name);
    }
369529
private static function getFilename($name, $directory)
    {
        $filename = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $filename .= str_replace('.phar', '', $name) . '.phar';

        return $filename;
    }
436385
private ProjectFile handleFileInDirectory(File directory) throws Exception
   {
      List<File> directories = new ArrayList<File>();
      File[] files = directory.listFiles();

      if (files != null)
      {
         // Try files first
         for (File file : files)
         {
            if (file.isDirectory())
            {
               directories.add(file);
            }
            else
            {
               UniversalProjectReader reader = new UniversalProjectReader();
               ProjectFile result = reader.read(file);
               if (result != null)
               {
                  return result;
               }
            }
         }

         // Haven't found a file we can read? Try the directories.
         for (File file : directories)
         {
            ProjectFile result = handleDirectory(file);
            if (result != null)
            {
               return result;
            }
         }
      }
      return null;
   }
152255
public void addDirectory(File dir) {
    File[] ndirs = new File[directories.length + 1];
    System.arraycopy(directories, 0, ndirs, 0, directories.length);
    ndirs[ndirs.length - 1] = dir;
    directories = ndirs;
  }
125631
public PurgeResponse purgeDirectory(String directory) {
        return purge(new PurgeRequest().addTask(new PurgeTask().withDirectory(directory)));
    }
1070188
public static File saveFile(String name, String data) {
        if (name == null) {
            name = "";
        }
        String fullyQualifiedName = name;

        /**
         * if filename is not absolute use current path as base dir
         */
        if (!new File(fullyQualifiedName).isAbsolute()) {
            fullyQualifiedName = Paths.get("").toAbsolutePath().toString() + "/" + name;
        }
        try {
            //create subdirs (if there any)
            if (fullyQualifiedName.contains("/")) {
                File f = new File(fullyQualifiedName.substring(0, fullyQualifiedName.lastIndexOf("/")));
                f.mkdirs();
            }
            File file = new File(fullyQualifiedName);
            file.createNewFile();
            FileUtils.write(file, data, "UTF-8");
            log.info("Wrote: " + file.getAbsolutePath());
            return file;
        } catch (IOException e) {
            log.log(Level.SEVERE, "Could not create file " + name, e);
            return null;
        }
    }
1176722
private void loadCertificatesFromDirectory(File directory) {

    directorySanityChecks(directory);

    synchronized (listenerLock) {
      listener.notifyCertficateLookupEvent(directory.getAbsolutePath());
    }

    File[] certFiles = directory.listFiles(new FilenameFilter() {

      public boolean accept(File dir, String name) {

        return name.endsWith(CERTIFICATE_FILENAME_SUFFIX);
      }
    });

    for (File f : certFiles)
      loadCertificateFromFile(f);

  }
533553
public File createFile(File dir, String filename) throws DataUtilException {
        if(dir == null) {
            throw new DataUtilException("The directory parameter can't be a null value");
        }
        try {
            File file = new File(dir, filename);
            return createFile(file);
        } catch (Exception e) {
            throw new DataUtilException("Invalid file: " + filename);
        }
    }
269937
public static int checkDirectoryArray(final String[] names) {
    int count = 0;
    for (int i = 0; i < names.length; i++) {
      if (names[i] != null) {
        final File dir = new File(names[i]);
        if (dir.exists() && dir.isDirectory()) {
          count++;
        } else {
          names[i] = null;
        }
      }
    }
    return count;
  }
471083
private ArrayList<String> getFiles(String dir, String subDir) {
    ArrayList<String> files = new ArrayList<>();
    String fullDir = subDir == null ? dir : dir + File.separator + subDir;
    File[] listOfFiles = (new File(fullDir)).listFiles();
    if (listOfFiles != null) {
      for (File file : listOfFiles) {
        String fullName = subDir == null ? file.getName() : subDir + File.separator + file.getName();
        if (file.isFile()) {
          files.add(fullName);
        } else if (file.isDirectory()) {
          files.addAll(getFiles(dir, fullName));
        }
      }
    }
    return files;
  }
19516
private String buildFileName(final String... names) {
        final StringBuilder builder = new StringBuilder();
        for (int i = 0; i < names.length; i++) {
            builder.append(names[i]);
            if (i < names.length - 1) {
                builder.append(SEPARATOR);
            }
        }
        builder.append(".").append("csv");
        return builder.toString();
    }
1134284
protected final boolean tryCP(String directory){

		String[] cp = StringUtils.split(System.getProperty("java.class.path"), File.pathSeparatorChar);
		for(String s : cp){
			if(!StringUtils.endsWith(s, ".jar") && !StringUtils.startsWith(s, "/")){
				String path = s + File.separator + directory;
				File file = new File(path);
				if(this.testDirectory(file)==true){
					//found using class path
					try{
						this.url = file.toURI().toURL();
						this.file = file;
						this.fullDirectoryName = FilenameUtils.getPath(file.getAbsolutePath());
						this.setRootPath = directory;
						return true;
					}
					catch (MalformedURLException e) {
						this.errors.addError("init() - malformed URL for file with name " + this.file.getAbsolutePath() + " and message: " + e.getMessage());
					}
				}
			}
		}
		return false;
	}
913153
@Override
    public FatLfnDirectoryEntry addDirectory(String name) throws IOException {
        checkWritable();
        checkUniqueName(name);
        
        name = name.trim();
        final ShortName sn = makeShortName(name);
        final FatDirectoryEntry real = dir.createSub(fat);
        real.setShortName(sn);
        final FatLfnDirectoryEntry e =
                new FatLfnDirectoryEntry(this, real, name);
        
        try {
            dir.addEntries(e.compactForm());
        } catch (IOException ex) {
            final ClusterChain cc =
                    new ClusterChain(fat, real.getStartCluster(), false);
            cc.setChainLength(0);
            dir.removeEntry(real);
            throw ex;
        }
        
        shortNameIndex.put(sn, e);
        longNameIndex.put(name.toLowerCase(Locale.ROOT), e);

        getDirectory(real);
        
        flush();
        return e;
    }
67693
private static void getFilesByNameRecursive(Collection<File> filesList, File path, String name)
    {
        Optional.ofNullable(path.listFiles()).ifPresent(files -> Arrays.asList(files).forEach(content ->
        {
            if (content.isFile() && content.getName().equals(name))
            {
                filesList.add(content);
            }
            else if (content.isDirectory())
            {
                getFilesByNameRecursive(filesList, content, name);
            }
        }));
    }