Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 18th, 2008, 05:42 AM
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to sorti file contents

Hello ., can anybody help me, how to sort the data in a file, i have a file with following data

/rainrate_2006_28_0_12_24_hour.dat
/rainrate_2006_29_0_7_24_hour.dat
/rainrate_2006_29_0_12_24_hour.dat
/rainrate_2006_29_0_1_24_hour.dat
/rainrate_2006_28_0_12_24_hour.dat ..etc..

How to write a code for sorting this type of data.. plz help me..

Reply With Quote
  #2 (permalink)  
Old March 19th, 2008, 03:54 AM
jomet
Guest
 
Posts: n/a
Default

using FileInputStream read the file
use readLine() to read line by line
store it in array or arraylist or vector
and sort

using vector..

java.util.Vector test = new java.util.Vector ( ) ;
 test.addElement ( "hello" ) ;
 test.addElement ( "lakshmi" ) ;
 test.addElement ( "anna" ) ;
 java.util.Collections.sort ( test ) ;
 System.out.println ( test ) ;

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
  #3 (permalink)  
Old March 19th, 2008, 05:41 AM
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank u very much jomet..

Reply With Quote
  #4 (permalink)  
Old March 19th, 2008, 11:15 PM
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hava tried the above method, but it is not sorting. it is displaying as it is in the file...



Reply With Quote
  #5 (permalink)  
Old March 20th, 2008, 05:26 AM
jomet
Guest
 
Posts: n/a
Default

put your code also

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking the contents of a text file for log-in Seifer Classic ASP Basics 10 December 18th, 2006 12:45 PM
export the contents of Datagrid to Excel file softsea VS.NET 2002/2003 0 October 4th, 2006 02:38 PM
Extracting contents of a war file.. Pallav J2EE 1 September 24th, 2004 12:02 PM
Dividing contents of 1 excel file into many Wire Excel VBA 1 April 12th, 2004 05:44 AM
How do I Save a form's contents into a .txt file flyingfox Pro VB.NET 2002/2003 2 March 28th, 2004 01:03 PM



All times are GMT -4. The time now is 04:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.