I have a program which opens a command line session in which inserts 2 words. To read these words i've previously used a batch script with the following command : echo word1=%1 word2=%2 >> C:\abc.txt
. Now i have to do that with Java.
Do you have any ideas how could I put this command cmd.exe /C echo user=%1 pass=%2 >> C:\abc.txt
in Java ProcessBuilder?
I've tried ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/C echo user = '%1' password = '%2' >> \"C:\\abc.txt\"");
but without success.
After I run my java app the content of abc.txt
is user = '%1' password = '%2'
but it should be something like that: user = John password = Doe
. Thank you in advance !