I need to be able to open a Windows Explorer window from my java program and highlight the specified file. I read How to use java code to open Windows file explorer and highlight the specified file? and intend to use the following recommendation from @krock :
Process p = new ProcessBuilder("explorer.exe", "/select,C:\\directory\\selectedFile").start();
But the problem I'm having is that my file path has white spaces, so it's just opening to my home folder. @krock mentioned that you have to escape spaces to get around white spaces, but I must not be doing it right.
Can someone please give an example of exactly how to correctly escape spaces in the following code so that my java program opens Windows Explorer to the correct folder (and still highlights the file)?:
Process newWindowsExplorerWindow = new ProcessBuilder("explorer.exe", "/select,C:\\Users\\Public\\Music\\Sample Music\\mySong.mp3").start();