I have (in java),
rt.exec("qq.exe -i ..(some other parameters) > qq.log");//*1
when I run qq.exe -i ..(some other parameters) > qq.log in terminal It works fine and keeps the qq.log file correctly.
However using rt.exec (*1) doesnt work. ” > qq.log” part causes problem. When I delete that part rt.exec (*1) works but I cant have qq.log file this time.
What causes this problem and Is there any soln??
rt.exec()can’t execute sh/bat code. It’s just invoking another program. When you try to redirect the output stream of qq.exe with the>symbol, which is specific to shell, java doesn’t understand what to do.An alternative is when you execute some program with the
execmethod, get theProcessreturned byrt.exec().A
Processcan give you an OutputStream to the application, an InputStream from the application and even an ErrorStream for a started application.With the InputStream, you can programmatically read the result of qq.exe and all you have to do is to write this into a file.