Hi, I created a little
java program under windows 2000 that's supposed to run a dir command and return the output to standard output. Unfortunately, the actual output doesn't look right, can someone help me out? Here's the code:
import java.io.*;
public class SysTest {
public static void main (
String args[]) {
String cmd = "command.com /c dir /w";
try {
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String thestring = null;
while ( (thestring = in.readLine()) != null ) {
System.out.println(thestring);
}
}
catch (Exception e) {
System.out.println("caught exception");
}
}
------
here's how the output should look like:
[.] [..] appletviewer.exe dt_shmem.dll
dt_socket.dll extcheck.exe HtmlConverter.bat idlj.exe
jar.exe jarsigner.exe java.exe javac.exe
javadoc.exe javah.exe javap.exe javaw.exe
jdb.exe jdwp.dll keytool.exe ListC.class
ListC.java native2ascii.exe oldjava.exe oldjavac.exe
oldjavaw.exe oldjdb.exe policytool.exe rmic.exe
rmid.exe rmiregistry.exe serialver.exe SysTest.class
SysTest.java SysTest.java~ tnameserv.exe unregbean.exe
here's the actual output:
[.] ☺☺☺☺☺☺☺☺☺☺ [..] ☺☺☺☺☺☺☺☺☺ APPLET~1.EXE DT_SHMEM.DLL DT_SOC~1.DLL
EXTCHECK.EXE HTMLCO~1.BAT IDLJ.EXE ☺☺☺ JAR.EXE ☺☺☺☺ JARSIG~1.EXE
JAVA.EXE ☺☺☺ JAVAC.EXE ☺☺ JAVADOC.EXE JAVAH.EXE ☺☺ JAVAP.EXE ☺☺
JAVAW.EXE ☺☺ JDB.EXE ☺☺☺☺ JDWP.DLL ☺☺☺ KEYTOOL.EXE LISTC~1.CLA
LISTC~1.JAV NATIVE~1.EXE OLDJAVA.EXE OLDJAVAC.EXE OLDJAVAW.EXE
OLDJDB.EXE ☺ POLICY~1.EXE RMIC.EXE ☺☺☺ RMID.EXE ☺☺☺ RMIREG~1.EXE
SERIAL~1.EXE SYSTES~1.CLA SYSTES~1.JAV SYSTES~2.JAV TNAMES~1.EXE
UNREGB~1.EXE