commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roger Crerie <roger.cre...@hds.com>
Subject [cli] absolute file path parsing
Date Tue, 15 Aug 2017 14:55:31 GMT
I am using the apache.commons.cli CommandLineParser and am running into the following problem.....

$ java -jar ./target/sorteria-0.0.1-SNAPSHOT-jar-with-dependencies.jar -f C:\shared\HCPAnywhere\AW001_3.0.0.20.iso
-t ISO
test = C:sharedHCPAnywhereAW001_3.0.0.20.iso
File = C:sharedHCPAnywhereAW001_3.0.0.20.iso

When getting the -f option which is going to be an absolute file path the parser removes the
\ character.  If I use \\ this works fine

$ java -jar ./target/sorteria-0.0.1-SNAPSHOT-jar-with-dependencies.jar -f C:\\shared\\HCPAnywhere\\AW001_3.0.0.20.iso
-t ISO
test = C:\shared\HCPAnywhere\AW001_3.0.0.20.iso
File = C:\shared\HCPAnywhere\AW001_3.0.0.20.iso


I don't want the end user of this tool to have to know to do this though.  Is there a way
for the parser to handle the \ character?  Maybe in the creation of the options?  What I have
for creating this option is....

Option file = new Option("f", "file", true, "Absolute File and Location");
        file.setRequired(true);
        options.addOption(file);

Roger
Roger.crerie@hds.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message