• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

interpretation of command line parameter

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

Look at this tiny little class:



Invocation with the following parameters:

one two three

will generate the output:

argument0:one
argument1:two
argument2:three

Nothing special so far.

Now I change the parameters to:

one *.xml three

The working directory contains two xml-files: abc.xml and xyz.xml

The output is:
argument0:one
argument1:abc.xml
argument2:xyz.xml
argument3:three

Wow! The java-command automatically expands filenames containing wildcards!
Nice feature....but I want the output look like this:

argument0:one
argument1:*.xml
argument2:three

Any ideas ?

Jens
[ April 21, 2008: Message edited by: Jens M Mayer ]
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not Java doing this, it's the shell you're typing this in. I think surrounding the parameters with double quotes (like "*.xml") will prevent it from happening. The specifics may depend on the shell, though.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wrap *.xml in quotes, like java test one "*.xml" three
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

wrap *.xml in quotes, like java test one "*.xml" three


Isn't that precisely what I suggested?
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic