Writing to a file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kim_Zuber
Posted On:   Tuesday, September 23, 2003 02:43 PM

Why does this code work in Eclipse but after compiling and running from the command line it does not save the file?


String strReadDB;


strReadDB = ("cmd /c p:\pvcs\vm7.5\vm\win32\bin\admin\readdb -p -ap:\pvcs\arc\" + m_vmdGroupName + "\pdbconfig\" + m_vmdGroupName + ".db > c:\temp\readdbdata.txt");

Process pr = Runtime.getRuntime().exec(strReadDB);

pr.waitFor();



the simple > c:\temp\readdbdata.txt should do it, right?

Thanks,

Kim

Re: Writing to a file

Posted By:   Simon_Ablett  
Posted On:   Wednesday, September 24, 2003 07:29 AM

You need to grab the process' output stream and redirect it to an appropriate file (look at 'Process.getInputStream').
See the excerpt from the JVM API documentation below.



Process::getInputStream

public abstract InputStream getInputStream()

Gets the input stream of the subprocess. The stream obtains data piped from the standard output stream of the process represented by this Process object. Implementation note: It is a good idea for the input stream to be buffered. Returns the input stream connected to the normal output of the subprocess.



Regards.
About | Sitemap | Contact