apache.commons.io 노트 1

3707 단어 commons
  ,        ,         ,     ,     ,    ,    ……

   1.4  。

public static void main(String[] args) throws IOException {
//   org.apache.commons.io.comparator.PathFileComparator
//   org.apache.commons.io.comparator.LastModifiedFileComparator
//   org.apache.commons.io.comparator.SizeFileComparator
  
//   org.apache.commons.io.filefilter.SuffixFileFilter
  
//   org.apache.commons.io.input.NullInputStream
//   org.apache.commons.io.input.AutoCloseInputStream
  
//   org.apache.commons.io.FilenameUtils.getExtension(filename)
//   org.apache.commons.io.FilenameUtils.removeExtension(filename)
//   org.apache.commons.io.FilenameUtils.getFullPathNoEndSeparator(filename)
//   org.apache.commons.io.FilenameUtils.indexOfExtension(filename)
  
   long f = org.apache.commons.io.FileSystemUtils.freeSpaceKb("c:");
   System.out.println(f);
  
   //org.apache.commons.io.FileSystemUtils            cmd   ,List performCommand(String[] cmdAttribs, int max) throws IOException {
}


public static void test_FileUtils() throws IOException {
   long begin = System.currentTimeMillis();
//   String content = org.apache.commons.io.FileUtils.readFileToString(new File("c:/a.txt"), "UTF-8");

//   org.apache.commons.io.FileUtils.writeByteArrayToFile(file, data)
//   org.apache.commons.io.FileUtils.cleanDirectory(arg0)
//   org.apache.commons.io.FileUtils.copyDirectory(srcDir, destDir)
//   org.apache.commons.io.FileUtils.copyURLToFile(arg0, arg1)
//   org.apache.commons.io.FileUtils.copyFileToDirectory(srcFile, destDir)
//   org.apache.commons.io.FileUtils.lineIterator(file)
//   org.apache.commons.io.FileUtils.moveDirectory(srcDir, destDir)
//   org.apache.commons.io.FileUtils.moveFile(srcFile, destFile)
   //             
//   org.apache.commons.io.FileUtils.touch(arg0)
//   org.apache.commons.io.FileUtils.writeLines(file, lines)
//   org.apache.commons.io.FileUtils.writeStringToFile(file, data, encoding)

   //   58 ,   6s
   long dirsize = org.apache.commons.io.FileUtils.sizeOfDirectory(new File("I:/     /  "));

   long end = System.currentTimeMillis();
   System.out.println(dirsize + " " + ((end - begin)/1000) + "s");

   FileUtils.checksumCRC32(file);
   System.out.println(FileUtils.byteCountToDisplaySize(584235));//     M   K
    //FileUtils.contentEquals(file1, file2)
   FileUtils.cleanDirectory(directory);
   FileUtils.writeStringToFile(file, data, encoding);

   File destination=new File("c:/new.html");
   URL source = new URL("http://news.baidu.com/");
   FileUtils.copyURLToFile(source, destination);

   FileUtils.isFileNewer(file, date);
   FileUtils.isFileOlder(file, reference);
   FileUtils.isFileOlder(file, timeMillis);
   FileUtils.iterateFiles(directory, fileFilter, dirFilter);

   LineIterator i = FileUtils.lineIterator(new File("c:/abcd.txt"));
   while(i.hasNext()){
   System.out.println(i.nextLine());
   }

   FileUtils.listFiles(directory, extensions, recursive);
   FileUtils.listFiles(directory, fileFilter, dirFilter);
   FileUtils.readFileToString(file);
   System.out.println(FileUtils.sizeOfDirectory(new File("E:/photo")));//    
   System.out.println(FileSystemUtils.freeSpaceKb("E:")+"k");
   System.out.println(freeSpaceWindows("E:"));
}

좋은 웹페이지 즐겨찾기