Wednesday, June 11, 2025

[JAVA] INFO STORAGE

     import java.io.File;

     public class DiskSpace {
         public static void main(String[] args) {
             File file = new File("/"); // Root directory
             long freeSpace = file.getFreeSpace();
             long totalSpace = file.getTotalSpace();
             long usableSpace = file.getUsableSpace();

             System.out.println("Free space: " + freeSpace + " bytes");
             System.out.println("Total space: " + totalSpace + " bytes");
             System.out.println("Usable space: " + usableSpace + " bytes");
         }
     }

No comments: