Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: a big issue

  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a big issue

    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Collections;
    import java.util.StringTokenizer;

    public class FileRead {

    public static void main(String[] args) throws IOException {
    String s = "Billing modes except annual will include a $2.00 billing fee. To save the fee, select EFT as a safe and secure payment option.";
    Client[] clients = new Client[25];
    ArrayList list = new ArrayList();
    FileInputStream fstream = new FileInputStream("C:\\Client1.txt");
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    int count =0;
    while ((strLine = br.readLine()) != null && count <25) {
    //System.out.println (strLine);
    Client client = new Client();
    StringTokenizer tokenizer = new StringTokenizer(strLine);
    client.setClientKey(tokenizer.nextToken());
    client.setClientNumber(tokenizer.nextToken());
    client.setClientName(tokenizer.nextToken());
    client.setDivision(tokenizer.nextToken());
    client.setCsPhone(tokenizer.nextToken());
    client.setGroupPolNumber(tokenizer.nextToken());
    client.setAbbreviation(tokenizer.nextToken());
    client.setPay1AutoPay(tokenizer.nextToken());
    client.setPay2CreditCard(tokenizer.nextToken());
    client.setPay3BillMeLater(tokenizer.nextToken());
    client.setPlanType(tokenizer.nextToken());
    client.setStandardName(tokenizer.nextToken());
    client.setEnhancedWithoutOrthoName(tokenizer.nextToken());
    client.setEnhancedWithOrthoName(tokenizer.nextToken());
    client.setBillingFee(s);
    client.setSecurityCode(tokenizer.nextToken());

    clients[count] = client;
    count ++;

    }


    for(int itr =0; itr <25;itr++){
    System.out.println(clients[itr].getClientKey() +clients[itr].getClientNumber() +clients[itr].getClientName()
    +clients[itr].getDivision() +clients[itr].getCsPhone() +clients[itr].getGroupPolNumber()
    +clients[itr].getAbbreviation() +clients[itr].getPay1AutoPay() +clients[itr].getPay2CreditCard()
    +clients[itr].getPay3BillMeLater() +clients[itr].getPlanType() +clients[itr].getStandardName()
    +clients[itr].getEnhancedWithoutOrthoName() +clients[itr].getEnhancedWithOrthoName()
    +clients[itr].getSecurityCode() +clients[itr].getBillingFee());
    //System.out.println(clients[itr].getBillingFee() +clients[itr].getSecurityCode());
    }

    }
    }

    now i need to sort the client array in ascending and descending order.
    Last edited by Rahulaa; 04-19-2011 at 06:28 AM. Reason: to make it more descriptive

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by Rahulaa View Post
    nhow i need to sort this array
    You already have:
    PHP Code:
            Arrays.sort(clients); 
    You may be arbitrarily sorting though, make sure Client implements Comparable<Client> interface.

    In the future, please select a more descriptive title of the issue, and wrap all code in [code][/code] or [php][/php] tags to preserve formatting.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •