aspose file tools*
The moose likes Java in General and the fly likes Internationalization: command usage. How many argument in main() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Internationalization: command usage. How many argument in main()" Watch "Internationalization: command usage. How many argument in main()" New topic
Author

Internationalization: command usage. How many argument in main()

shell Johnson
Ranch Hand

Joined: Jul 17, 2002
Posts: 37
If I have command syntax usage like this:

listAllAccount -d <date> -o <owner name> -desc <description>
and need to support internationally. What I will get from main()? a single argument or multiple argument? The BreakIterator sample in API shows that args.length =1. Is this true?
public static void main(String args[]) {
if (args.length == 1) {
String stringToExamine = args[0];
//print each word in order
BreakIterator boundary = BreakIterator.getWordInstance();
boundary.setText(stringToExamine);
printEachForward(boundary, stringToExamine);
//print each sentence in reverse order
boundary = BreakIterator.getSentenceInstance(Locale.US);
boundary.setText(stringToExamine);
printEachBackward(boundary, stringToExamine);
printFirst(boundary, stringToExamine);
printLast(boundary, stringToExamine);
}
}
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Is your app started similar like this:

or

?
In the first case you have 7 arguments, with
args[0].equals ("listAllAccount"), args[1].equals ("-d").
In the second you have 6 arguments.

and if not?
If the first form is right, your args[0] and stringToExamine is 'listAllAccount'.
If you run your code you may insert a 'print'-Statement to verify.


http://home.arcor.de/hirnstrom/bewerbung
shell Johnson
Ranch Hand

Joined: Jul 17, 2002
Posts: 37
As your explanation, java will recognize localized "white space" or "word break" to break one single line into several arguments. Is this true? It seems that is it not what the BreakIterator sample shows. I'm on US locale. I always get 7 arguments. Is this true that I always get 7 arguments from all different locale?
Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149
This breaking apart of the parameters happens before Java kicks in.
That's done by the operating system.
To go one step farther, this is even OS dependant.
If you have a directory with a.txt and b.txt files and you decide to call

you will get
args[0] = a.txt, args[1] = b.txt on the UNIX shell
and
args[0] = *.txt on Windows
Ballyhoo,
J.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internationalization: command usage. How many argument in main()