desislava_topuzakova

8. Get Folder Size

Jun 1st, 2021
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.io.File;
  2. import java.nio.file.Path;
  3.  
  4. public class GetFolderSize_08 {
  5.     public static void main(String[] args) {
  6.         String path = "C:\\Users\\I353529\\Documents\\SoftUni\\Exercises Resources";
  7.         File folder = new File(path);
  8.  
  9.         int folderSize = 0;
  10.         for (File file : folder.listFiles()) {
  11.             folderSize += file.length();
  12.         }
  13.  
  14.         System.out.println("Folder size: " + folderSize);
  15.  
  16.     }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment