Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprivate void Load_DeviceActionPerformed(java.awt.event.ActionEvent evt) { try { Runtime.getRuntime().exec("cmd devcon status =floppydisk *"); Runtime.getRuntime().exec("cmd devcon status =diskdrive *"); // Récupération des périphériques présents }catch(Exception e) { System.out.println("Aucun Périphérique Détecté"); } }
/** * Cette procédure permet de lancer la récupération des flux dans un thread distinct * @param stream * Le flux à récupérer * @param destination * La liste dans laquelle on enregistre le résultat */ private void lancerRecuperationSortie(final InputStream stream, final List<String> destination){ new Thread() { public void run() { try { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line = ""; try { while((line = reader.readLine()) != null) { destination.add(line); } } finally { reader.close(); } } catch(IOException ioe) { ioe.printStackTrace(); } } }.start(); }
List<String> lignes = new ArrayList<String>(); Process process = runtime.exec(commande); lancerRecuperationSortie(process.getInputStream(), lignes);