The script works but I'm having a problem reading double and boolean
Code:
import java.io.*;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
public class FileAddress
{
public static void main(String [] args)
{
String aRecord; //for record
String accountNumber;
String customerName;
String customerPhone;
double customerBalance; //account balance
boolean accountStatus; //true if account is active, false if not
StringTokenizer strings;
try
{
FileReader inStream = new FileReader("account.txt");
BufferedReader ins = new BufferedReader(inStream);
while ((aRecord=ins.readLine())!= null)
{
strings = new StringTokenizer(aRecord,"?"); //toekenizer
if (strings.countTokens() == 5) {
accountNumber = strings.nextToken();
customerName = strings.nextToken();
customerPhone = strings.nextToken();
customerBalance = strings.nextToken(); //ERROR
customerStatus = strings.nextToken(); //ERROR
JOptionPane.showMessageDialog(null,accountNumber);
JOptionPane.showMessageDialog(null,customerName+" "+customerPhone+" "+customerBalance);
}
}
ins.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
Comment