Writing to a file
1 posts in topic
Flat View  Flat View

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);


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



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.


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.

About | Sitemap | Contact