Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-18-2011, 02:53 PM   PM User | #1
Rahulaa
New to the CF scene

 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rahulaa is an unknown quantity at this point
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 05:28 AM.. Reason: to make it more descriptive
Rahulaa is offline   Reply With Quote
Old 04-18-2011, 03:22 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:33 PM.


Advertisement
Log in to turn off these ads.