Reputation: 193
I want to run something similar to the following:
java MyProgram C:\Path\To\My\File
When I do this and output the contents of the first argument, it outputs:
C:PathToMyFile
This works, however:
java MyProgram "C:\Path\To\My\File"
But I want to be able to do the first command instead of the second. How can I achieve this?
Upvotes: 0
Views: 2473
Reputation: 4280
The \
charecter is used to "escape" special characters. This means it tells the program to ignore them, or not do anything special to them. To make this work just use \\
instead of \
. This escapes the \
. So use
C:\\Path\\To\\My\\File
Upvotes: 1