Executing UNIX system commands from Java problems

I encountered a strange problem when executing system commands from Java code

Runtime. getRuntime(). exec(“system_profiler -detailLevel full”);

This is working properly If I print out, it's cool But I want to write this information to the plist file for future use I use system for this_ profiler. Like's - XML parameter,

String cmd = "system_profiler -detailLevel full -xml > "+System.getProperty( "user.home" )+"/sysinfo.plist";
 Process p = Runtime.getRuntime().exec(cmd);

Basically, this should create a plist file in the current user's home directory

But it doesn't seem to have written any documents

Did I miss anything?

Solution

My java is not only rusty, so please keep gentle

The above is all the content collected and sorted out by the programming house for you to execute UNIX system commands from Java problems. I hope this article can help you solve the program development problems encountered in executing UNIX system commands from Java problems.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>