java - String substring or splitter - sorting data inserted from command line argument -


i'm trying input command line argument , sorting them according type. e.g. in cmd if user types

java myprog from:email@my.com to:email@your.com body:this message 

i've achieved "from" , "to" sorted using substring i.e

    x = args.length;      (int = 0; < x; i++) {             if (args[i].startswith("from:")) {                 = args[i].substring(5);             } else if(args[i].startswith("to:")) {                 = args[i].substring(3);             } else if (args[i].startswith("body:")) {                  body = args[i].substring(5);    // **i'm stuck here**         }     } 

this tried , works except body. because gives output "thisismessage" without space.

i tried splitting them well. couldn't work out.

what shall try?

i'm not expected change command line argument.

i expect output of body be: "this", not sure why "thisismessage". but, perhaps program "is" , "message" separate arguments. maybe last else if statement like:

else if (args[i].startswith("body:")) {      body = args[i].substring(5);    // **i'm stuck here**     while(i < x) {         i++;         body += " " + args[i];     }    } 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -