Home > Java > javaTutorial > Java Example - Get Directory Size

Java Example - Get Directory Size

黄舟
Release: 2017-02-13 10:06:15
Original
1453 people have browsed it

The following example demonstrates using FileUtils.sizeofDirectory(File Name) of the File class to obtain the size of the directory:

/*
 author by w3cschool.cc
 Main.java
 */import java.io.File;import org.apache.commons.io.FileUtils;public class Main {
   public static void main(String[] args) {
      long size = FileUtils.sizeOfDirectory      (new File("C:/test"));
      System.out.println("Size: " + size + " bytes");
   }
Copy after login

The output result of running the above code is:

Size: 2048 bytes
Copy after login

The above is the Java example - Get the content of the directory size. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template