• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Peculiar behaviour of java XXXXX *

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
giving
java xxxx *
at the command prompt

class xxxx
{
public static void main(String a[])
{
for(int i=0;i<a.length;i++)
{
System.out.println("xxxx " + i + ":" + a[i]);
}
}
}
lists out all the files and dirs inthe current directory? why does this happen what exactly happens?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This behaviour is because the Unix commandline has automatic wildcard expansion, which expands any given wildcard on the commandline to its matching filenames before turning control to the program.
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but this also happens on the windows system. what do u say about this?
 
Jaap van Hengstum
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My wrong... it seems that java is doing its own wildcard expansion (at least on Windows systems), by the way you can disable this by quoting the commandline argument, like:


myprogram "*"

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ernest,
Where are u man? I have been waiting for ur answer. After seeing many answers to the questions which i have posed i have been a great fan of you.
I thought you would help me out. kinldy look into the question and i am sure you will give me a correct answer and I am not flattering.
thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic