Using function equivalent to sscanf in JAVA
843829Mar 16 2006 — edited Mar 16 2006Hello,
All I want to do in java is to read the data saved in a buffer( a lot of numbers and characters seperated by semicolons) and organize it into columns of data saved in an outfile!!!! To this end each number or character seperated by a " ; " from the other has a special meaning and I need to save each one in a seperate variable to be able to use it in later simulation.I also dont know how much data is saved in the string. I just know that it is there and I need to extract it to something HUMAN readable.
So I have this string of numbers and letters saved in a buffer string s.
500 ; -5.0E-1 ; 4.0E-3 ; 2.0E-8 ; 0 ; "s" ; "V"
(ignore the spaces, I just wanted you to be able to read the characters easily)
So if I was using C I would ve simply use sscanf
sscanf( s , "%d;%e;%e;%e;%d;%[^;];%s", &nr_pt, &yoff, &ymult,
&xincr, &pt_off, xunit,yunit );
to read the data saved in s and save it to 7 other variables.
But how would I do this in JAVA, so desperate! Do I use some functions like read or read line or....
So here I knew that I have 7 variable, what if I do not know how many data points is saved in the string and I want to read one by one and save it or print it to a file!
Thanks,
Sanaz