I want to show you one funny thing!
The code is shown below is simplest that you can imagine and does very unusual thing!
It is slightly bigger than "Hello World!" program but does much more.
It lists all files in the current directory if you run it like this:
java test *
(of course after compilation) in DOS/CMD prompt on Windows or in any shell in UNIX.
The program shows all files both in Unix and Windows.
If you do: java test .*
on UNIX it also shows all hidden files.
class test{
public static void main(String args[]){
for (int i = 0;i <>
System.out.println("File " + i + ":" + args[i]);
}
if (args.length<=0) {
System.out.println("No files!");
}
}
}

No comments:
Post a Comment