Runtime problem

Can you please help me how to run this command with java (windows):

In console :

C:\Data> md5sum testing.zip > file.lst

I have tried :

===========================================================

String s = "md5sum testing.zip > file.lst";

try

{

Process p = Runtime.getRuntime.exec(s, null, "C:\Data\");

}

catch(IOException e)

{

e.printStackTrace();

}

===========================================================

seems OK, but the file.lst is not created.

Can you please help me ? Thank you.

[602 byte] By [Thunder_Blast] at [2007-11-26 12:17:58]
# 1
Open a FileOutputStream to "file.lst", get the InputStream from process p, read all data from the InputStream and pass it through to the OutputStream.
quitte at 2007-7-7 14:56:16 > top of Java-index,Archived Forums,Socket Programming...
# 2

You will need to invoke cmd to get redirection to work. Something along the lines of

String[] cmd = new String[]{"cmd.exe","/C","md5sum testing.zip > file.lst"};

Process p = Runtime.getRuntime.exec(cmd, null, "C:\Data\");

You might do better to read the output of 'md5sum testing.zip' into your Java program and then write the file from Java.

It would be well worth your time reading, digesting and implementing the advice given in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

sabre150 at 2007-7-7 14:56:16 > top of Java-index,Archived Forums,Socket Programming...