Use argument from the console JAVA -


i want use arguments console in ubuntu

./mytool -ip 1.2.3.4

how can tack\use 1.2.3.4 in code that

public static void main(string[] argv) throws exception {       for(int i=0;i<argv.length;i++)     {         if (argv[i].equals("-ip"))         {           ping(80,"the ip want(1.2.3.4)")         }      } } 

for more generic approach parsing cmdline arguments recommend using 1 of existing frameworks - heavy lifting you.

take @ jopt simple - 1 used eg. openjdk.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -