- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to calculate the size of folder using Java?
You can get the size of a directory with the help of FileUtils.sizeofDirectory(File Name) method of FileUtils class.
Example
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:/Windows")); System.out.println("Size: " + size + " bytes"); } }
Output
Size: 2048 bytes
- Related Articles
- How to calculate the Size of Folder using C#?
- How to get the folder size using PowerShell?
- How to calculate a directory size using Python?
- How to delete folder and sub folders using Java?
- How to get the directories (only) from a folder using Java?
- How to create a directory in project folder using Java?
- How to read all files in a folder to a single file using Java?
- How to zip a folder recursively using Python?
- How to share a windows folder using PowerShell?
- How to remove windows folder sharing using PowerShell?
- How to write files to the assets folder in android using Kotlin?
- Java Program to calculate the power using recursion
- How to change SMB shared folder access permission using PowerShell?
- How to copy files from one folder to another using Python?
- How to get list of all files/folders from a folder in Java?

Advertisements