+ 2

I want to pass 2 args in the cmd but one of the arguments has a space in them so it is taken as 3 arguments? What must i do?

I have a java program that takes two command line arguments. The program copies the contents of the first file into the second file.The arguments must be the paths of two files but one path has a space in it so cmd takes it as 3 args. I tried using double quotes but it does not help. Please tell me what to do. P.S. I am using Windows.

17th Dec 2018, 2:51 PM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
6 ответов
+ 4
Use the Scanner nextLine() method. My idea is to tell the user to separate paths by ','. So you could store the paths in an array using split(",") method.
18th Dec 2018, 1:22 PM
Seniru
Seniru - avatar
+ 3
Seniru Pasan thanks for the idea I will try that.
19th Dec 2018, 8:35 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
0
Use an underscore as there should be no gaps in arguments like this, one_argument.
17th Dec 2018, 5:18 PM
Monya 🇮🇶
Monya 🇮🇶 - avatar
0
It's weird cause usually single quote or double quote should solve the problem.
17th Dec 2018, 7:26 PM
Erick Adinugraha
Erick Adinugraha - avatar
0
Use an underscore instead of a space,space is usually called a whitespace character in java
17th Dec 2018, 9:27 PM
Codebeast**
Codebeast** - avatar
0
Codebeast** it says that it can't find the file when I use an underscore where the space supposed to be
18th Dec 2018, 12:02 PM
Shuaib Nuruddin
Shuaib Nuruddin - avatar