Skip to content
Advertisement

How to run sed command from java code

I’m probably missing something, but I’m trying to run commandline from a java

The code is as following:

JavaScript

I’m getting the following error:

JavaScript

The fils is exists. I’m doing ll on this file and it is exists. I’m just looking for a way to make it work from java. What am I doing wrong?

Advertisement

Answer

Pass the command as an array, not a string:

JavaScript

See ProcessBuilder documentation.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement