I want to call cmd command in java code. I say:
String str ="C:/uploaded_files/111.txt";
Process process = Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c",str});
System.out.println(str);
And dont get 111.txt
. Its strange because when this code was in jsp
all works fine. What can be wrong?
I hope It is not cmd.exe Please try this:
If you want to open the file in notepad try this.
Hope it's the one you want.
what's the problem with this code. It's perfectly working. opens and shows content of the file 111.txt
please check whether the path is correct and whether the directories and files are not missed or spelled