1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public void chargelist (){
File[] roots = File.listRoots();
String[] taille = new String[roots.length];
File[] names ;
String[] unites = new String[] { " octets", " Ko", " Mo", " Go", " To" };
DecimalFormat df = new DecimalFormat("####.##");
FileSystemView v = FileSystemView.getFileSystemView();
for (int i = 0; i < roots.length; ++i){
double tmpSize = roots[i].getTotalSpace();
int u = 0;
while (tmpSize >= 1024) {
tmpSize /= 1024.0;
u++;
}
taille[i]= df.format(tmpSize) + unites[u];
names[i] = v.getSystemDisplayName(roots[i]);
}
liste1 = new JList(roots);
liste2 = new JList(taille);
liste3 = new JList(names);
} |