-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowDrives.java
More file actions
27 lines (18 loc) · 818 Bytes
/
ShowDrives.java
File metadata and controls
27 lines (18 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.File;
import javax.swing.filechooser.FileSystemView;
public class ShowDrives {
public static void main(String[] args) {
FileSystemView fsv = FileSystemView.getFileSystemView();
File[] drives = File.listRoots();
if(drives.length > 0 && drives != null) {
for(File drive : drives) {
System.out.println("------------------");
System.out.println("Drive Name: " + drive);
System.out.println("Drive type: " + fsv.getSystemTypeDescription(drive));
System.out.println("Total Space: " + drive.getTotalSpace()/(1024*1024*1024) + " GB");
System.out.println("Total Free Space: " + drive.getFreeSpace()/(1024*1024*1024) + " GB");
System.out.println("Total Usable Space: " + drive.getUsableSpace()/(1024*1024*1024) + " GB");
}
}
}
}