Previous Next JavaScript must be enabled to correctly display this content

## UpdateJSON.parseArgs()

The `UpdateJSON.parseArgs()` method is used to parse the command line arguments used with this class at run time.

It is unlikely that this method holds any surprises for Java programmers. It is included here purely for the sake of completeness.

        // Parse command line arguments
        private void parseArgs(String[] args)
        {
            final int nArgs = args.length;
            int argc = 0;
            ArrayList<String> hhosts = new ArrayList<String>();

            while (argc < nArgs) {
                final String thisArg = args[argc++];

                if (thisArg.equals("-store")) {
                    if (argc < nArgs) {
                        storeName = args[argc++];
                    } else {
                        usage();
                    }
                } else if (thisArg.equals("-hostport")) {
                    if (argc < nArgs) {
                        hhosts.add(args[argc++]);
                    } else {
                        usage();
                    }
                } else if (thisArg.equals("-file")) {
                    if (argc < nArgs) {
                        dataFile = args[argc++];
                    } else {
                        usage();
                    }
                } else if (thisArg.equals("?") ||
                        thisArg.equals("help")) {
                    usage();
                } else {
                    usage();
                }
            }

            if (hhosts.isEmpty()) {
                helperhosts = new String [] {defaulthost};
            } else {
                helperhosts = new String[hhosts.size()];
                helperhosts = hhosts.toArray(helperhosts);
            }
        }
    }