Krish Nakum R Krish Nakum R - 8 months ago 47
Java Question

Unable to open file in explorer when there comma in file name

Hi I tried to open a file in explorer for a chat application using java, using the code

Runtime.getRuntime().exec("explorer.exe /select," + recievedFile);

It works fine except when there is
in file name.

I cannot replace
with empty space or some other characters because I have to preserve the file name.

Any other possibilities? Without altering the file name? I must have the file selected and opened in a new explorer window. Thanks.


You can change your code like this to able to open files with comma in file name:

Runtime.getRuntime().exec("explorer.exe /select,\"" + recievedFile + "\"");