How to scan ':' delimitted integer inputs in java? -


i have input of integers :

2 90:01:23 42:01 12:89:21 21:67 

i tried using

line = scan.nextline() ;   string[]  tokens =  line.split(":| ");  int first =  integer.parseint( tokens[0]); 

but gives me

numberformatexception 

i want parse these int 5 variables.

the input parsed must in order :

90, 1, 23, 42, 1 

please me parse input.

you can this:

string s = " 90:01:23 42:01"; s = s.trim(); string[] sarr = s.split(":|\\s+"); for(string str : sarr) {     system.out.println(integer.parseint(str)); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -