Counting and displaying number of accounts not empty

+2 rich mon · November 29, 2014

public static void BankFiles()
{
final String EMPTY_ACCT = "0000";
final String ID_FORMAT = "0000";
   final String NAME_FORMAT = "        ";
final String BALANCE_FORMAT = "00000.00";
Path file = Paths.get("C:\\EJava\\Assign9\\Account.txt");

String delimiter = ",";
String s = ID_FORMAT + delimiter + NAME_FORMAT + delimiter + BALANCE_FORMAT + System.getProperty("line.separator");

String[] array  = new String[3];

        try
{
  InputStream input = new BufferedInputStream(Files.newInputStream(file));
  BufferedReader reader = new BufferedReader(new InputStreamReader(input));     

 while(s != null)
 {
   array = s.split(delimiter);
    if(!array[0].equals(EMPTY_ACCT))
    { 
  area.append("Customer #: "+ array[0] + "  "+ " Name: "+ array[1] + "" + "Balance: " + "$" + array[2] + System.getProperty("line.separator"));            
 
       totacct.setText(array[0]);
    }    
       s = reader.readLine();                                          
  }        
       reader.close();
}
catch(Exception e)
     {
   System.out.println("Message: " + e);
     } 
        
}

Hello,
I'm trying to write a loop that counts the the total number of files that have an account number in them that aren't empty and pass the value to the JTextField.   Thanks in advance.

Post a Reply

Replies

Oldest  Newest  Rating
0 rich mon · November 29, 2014
good   morning,
My problem is constructing the loop.  I stuck on how to set the loop up.  
  • 1

Java / Android Development

107,170 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator