java - Process command line arguments -


we have shell script invokes java program. script passes arguments values methods defined in main method of java program.

the expected input format parameters follows

"test1, test1_21apr15,xyz,test,test, , , 2015-04-21"   "test2, test2_21apr15,xyz,test,test, , ,2015-04-21"    "test3,test3_21apr15,xyz, test,test, , ,2015-04-21" 

and on, i.e. each string has attributes comma separated , string separated space (here have mentioned in next line actual values separated space).

from above input values need assign values local attributes shown below:

attr1 = test1,test2,test3    attr2 = test1_21apr15,test2_21apr15,test3_21apr15   attr3 = xyz,xyz,xyz   attr4 = test,test,test    .   .   .   attr8 = 2015-04-21,2015-04-21,2015-04-21, 

and need process these parameters in methods.

i understand when pass arguments main method placed in arg[] array, facing issues while assigning parameters values attributes.

can please give me guidance me on this? in advance.

if pass each set "," separated instead of space separated

"test1, test1_21apr15,xyz,test,test, , , 2015-04-21, test2, test2_21apr15,xyz,test,test, , ,2015-04-21" 

then use following logic here "testnum" number of input lines referring , "testlen" number of strings in each line.

for(int i=0;i<testlen;i++){  for(int j=0;i<testnum;j++){      attr[i]=attr[i]+args[j*testlen+i]   if(j<testnum-1)      attr[i]=attr[i]+",";  } }  

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -