2018년 4월 2일 월요일

[Java] How to get system root drive information


1. Get Root Drive Information 


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
package javautility;

import java.io.File;
import javax.swing.filechooser.FileSystemView;

public class FileUtil {
    public static void printRootLists() {
        FileSystemView fsv = FileSystemView.getFileSystemView();
        File[] paths = File.listRoots();
        for( File f : paths ) {
            System.out.println( f.getPath() + "(" + fsv.getSystemTypeDescription(f) + ")" );
        }
    }
}


Result:
C:\(로컬 디스크)
D:\(로컬 디스크)
F:\(USB 드라이브)
H:\(USB 드라이브)
Z:\(네트워크 드라이브)



댓글 없음:

댓글 쓰기