I want to write a program which will detect the drive letter when a usb device is plugged in. i.e., if a usb device is plugged in and the drive letter is "E:", then my program will instantly detect the presense of the device as well as get the drive letter. How's that possible in Java?

Also, I want to set or remove a file attribute (read-only/hidden etc.). How can I do it?