Hi
Suppose I have my program reading from a file with the following contents:
0.000,-0.073,-0.127,0.034,-0.034,0.146,0.098,0.029,-0.093,0.088,0.107
-0.005,-0.049,-0.112,0.039,-0.039,-0.059,-0.083,-0.020,-0.103,-0.068,-0.073
0.000,0.015,-0.049,0.010,0.308,-0.020,-0.054,0.225,-0.029,0.288,0.132
-0.005,0.020,0.068,0.088,-0.005,0.098,-0.044,0.098,0.073,0.098,-0.151
-0.005,-0.005,0.020,-0.015,-0.239,0.010,-0.024,0.181,-0.015,0.312,0.103
-0.005,-0.049,-0.044,0.044,-0.117,0.010,-0.054,0.244,0.034,-0.024,-0.103
0.000,-0.137,-0.122,-0.107,-0.601,0.093,0.020,-0.068,-0.205,-0.078,-0.039
and then I use StringTokenizer (delimiter ",") and feed the numbers into a vector.
File myFile = new File(strFileName); //Pass the file content to strFileName
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(myFile)));
StringTokenizer st1 = new StringTokenizer (inputLine, ",");
while ((inputLine = br.readLine()) != null)
{
v.addElement(inputLine.trim()); //passes the content of the file to a vector
}
br.close();
for (int i = 0; i < v.size(); i++)
{
System.out.println("Vector " + i +": " + v.get(i)); //returns content of the file as a Vector
I seem to be getting an error for the StringTokenizer(inputLine). Anyone know the problem?
My other question is how to extract the file into columns.
For example, the first column highlighted is one column and so on...
[B]0.000[/B],-0.073,-0.127,0.034,-0.034,0.146,0.098,0.029,-0.093,0.088,0.107
[B]-0.005[/B],-0.049,-0.112,0.039,-0.039,-0.059,-0.083,-0.020,-0.103,-0.068,-0.073
[B]0.000[/B],0.015,-0.049,0.010,0.308,-0.020,-0.054,0.225,-0.029,0.288,0.132
[B]-0.005[/B],0.020,0.068,0.088,-0.005,0.098,-0.044,0.098,0.073,0.098,-0.151
[B]-0.005[/B],-0.005,0.020,-0.015,-0.239,0.010,-0.024,0.181,-0.015,0.312,0.103
[B]-0.005[/B],-0.049,-0.044,0.044,-0.117,0.010,-0.054,0.244,0.034,-0.024,-0.103
[B]0.000[/B],-0.137,-0.122,-0.107,-0.601,0.093,0.020,-0.068,-0.205,-0.078,-0.039
Thanks in advance to those who helped. Appreciate it. =)