title: USB(Memory Stick),or any other drivers detection and listing their contents in JAVA
body: <p>Hey guys i am coding simple USB detection java app and i cant make detect my USB driver or any other drivers, how can i add driver detection? is there any ways or sample java app to detect drivers and its contents? any help would be appreciated</p>
  
  <p>how can i add this following code to my app?</p>
  
  <pre><code>public class USBdetection 
  {
  public static void main(String[] args)
  {   
  String[] letters = new String[]{ "E", "F", "G", "H", "I" ,"J","K", "L","M", "N"};
  File[] Externaldrives = new File[letters.length];
  boolean[] FoundDrive = new boolean[letters.length];
  
  // init the file objects and the initial drive state
  
      for ( int i = 0; i &lt; letters.length; ++i )
  {
  Externaldrives[i] = new File(letters[i]+":/");
  
  FoundDrive[i] = Externaldrives[i].canRead();
  }
  
  System.out.println("Waiting for device, Please Wait");
  
  // Search each drive
  while(true)
  {
  for ( int i = 0; i &lt; letters.length; ++i )
  {
  boolean pluggedIn = Externaldrives[i].canRead();
  
  // if the state has changed output a message
  if ( pluggedIn != FoundDrive[i] )
  {
  if ( pluggedIn )
  System.out.println("Drive "+letters[i]+" has been plugged in");
  
  FoundDrive[i] = pluggedIn;
  }
  
  }
  
  }
  }
  }k
  </code></pre>