Outputting result of “dir” to console in Java
问题 I want to output the result of the "dir" command to the java console. I have already looked on Google and here, but none of the examples work for me, thus making me rite this post. My code is as follows: try { System.out.println("Thread started.."); String line = ""; String cmd = "dir"; Process child = Runtime.getRuntime().exec(cmd); //Read output BufferedReader dis = new BufferedReader( new InputStreamReader(child.getInputStream() )); while ((line = dis.readLine()) != null) { System.out