I want to check by program if a flash drive (pen drive) is plugged into my computer. If I can detect that a flash drive is plugged in then all the contents will be copied to my computer invisibly. I've a idea to do that. But I think it's pretty bad.
String allDrives[] = {"A","B",....,"Z"};
while(true){
for(String drive : allDrives){
if(drive exists){
Do the required task
}
}
}
Is there any better idea to do that? Any help is appreciated.