If I want to run the Java program MyProgram from the command line and give it a text file located on the C drive called MyFile.txt as an argument, I know I have to type this:
Is there any way to handle the args in my main method so that a user wouldn't have to double escape the location of the file? In other words, I want to make it so a user can just type this:
It's not the end of the world, but if there's a way, I definitely wouldn't mind avoiding that extra step of confusion because I've got a bunch of programs controlled by Windows batch files and I can comment those so that the user will know what to do, but I figure just making it standard in the first place would cut down on frustration! Thanks...
The last solution would prevent to use the program in a script, when there is no user, to be prompted. Of course it could be used, if (args.length == 0), to support both.
Note that if you put your app into a jar-File, and have set up your system, how to handle .jars, and pull some marked files with the mouse to your jar, the application may handle them as array of strings of filenames, i.e. "file.a" "file containing a.blank" "file.b".