Java running linux command
I am trying to execute linux commant 'cat' from java code but it doesn't work.
Runtime.getRuntime().exec("cat /home/roman/logs/*");
And it works well for a single file cat
Runtime.getRuntime().exec("cat /home/roman/logs/mylog.log");
My question is how to get all the files in some directory from java?
+3
source to share
3 answers
Runtim.exec () does not use a shell to execute the command. Therefore, the wildcard is not expanded. Try the solution in Want to invoke linux shell command from java .
+2
source to share