Get Command Prompt Output to String In Java
I need a java method that will read command prompt output and store it into a String to be read into Java. This is what I have so far but isn't working right. public void testGetOutput() { System.out.println("\n\n****This is the testGetOutput Method!****"); String s = null; String query = "dir " + this.desktop; try { Runtime runtime = Runtime.getRuntime(); InputStream input = runtime.exec("cmd /c " + query).getInputStream(); BufferedInputStream buffer = new BufferedInputStream(input); BufferedReader commandResult = new BufferedReader(new InputStreamReader(buffer)); String line = ""; try {