Remove chars from string in Java from file -
how remove chars data in file sum numbers?
alice jones,80,90,100,95,75,85,90,100,90,92 bob manfred,98,89,87,89,9,98,7,89,98,78
i want every line remove chars not ints.
you can make use of split method of course, supplying "," parameter, that's not all.
the trick put each text file's line arraylist. once have that, move forwars pseudocode:
1) put each line of text file inside arraylist 2) each line, split array using "," 3) if array's size bigger 1, means there numbers summed up, else name lies on array , should continue next line 4) size bigger 1, iterate thru strings inside string[] array generated split function, 1 < size (this exclude name string itself)
5) use integer.parseint( iterated number string ) , sum
there go
number format exception occur if string not number putting each line arraylist , excluding name there should no problem :)
Comments
Post a Comment