StringTokenizer to.. double Array[ ]
From: Dimitris (dimitris123_at_gmail.com)
Date: 03/27/05
- Next message: Carramba: "Re: won't catch some chars"
- Previous message: Allan Bruce: "Re: Click Applet to Active !!!"
- Next in thread: Anthony Borla: "Re: StringTokenizer to.. double Array[ ]"
- Reply: Anthony Borla: "Re: StringTokenizer to.. double Array[ ]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Mar 2005 04:40:49 -0800
I am reading a .txt file, and trying to store each double number to an
array for further calculations.
I have problems adding the numbers to the array.
Here is what i am trying to do:
public void read(File afile) {
FileInputStream fInpStr = null;
BufferedReader bRead = null;
StringTokenizer strTok = null;
String line = null;
String next = null;
String[] jim;
int i = 0;
//temporary variables
String variableName;
double variableValue;
//open the variable text file and catch any error.
try {
fInpStr = new FileInputStream(afile);
}
catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "File not found " + afile,
"Error",
JOptionPane.ERROR_MESSAGE);
return;
}
variableName = "";
variableValue = 0.0;
try {
bRead = new BufferedReader(new InputStreamReader(fInpStr));
//first line
variableName = bRead.readLine();
while (strTok.hasMoreTokens()) {
}
// second line
line = bRead.readLine();
fInpStr.close();
}
catch (IOException e) {
System.out.println(e.toString());
JOptionPane.showMessageDialog(null, "Error reading file " +
afile,
"Error",
JOptionPane.ERROR_MESSAGE);
}
} //end of read
_______________________________________
this is the code so far for reading the values. I think i have to add a
for loop to "loop" through the array, but i am cofused.
- Next message: Carramba: "Re: won't catch some chars"
- Previous message: Allan Bruce: "Re: Click Applet to Active !!!"
- Next in thread: Anthony Borla: "Re: StringTokenizer to.. double Array[ ]"
- Reply: Anthony Borla: "Re: StringTokenizer to.. double Array[ ]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|