How to detect a usb drive in Java

前端 未结 2 1036
眼角桃花
眼角桃花 2021-01-21 05:36

I would like to know how to detect a usb drive. I have already read this post but I am interested in knowing if we can just use java.io.*; to check for the usb driv

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 05:45

    This works at least on Linux

    File f = new File("/media");
    for(File fls : f.listFiles()){
        System.out.print(fls+"\n");
    }
    

    Remember external plugged device storage on Linux can be found on /media

提交回复
热议问题