Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2008, 05:42 AM
Authorized User
 
Join Date: Apr 2007
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..

 
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.
 
Old March 19th, 2008, 05:41 AM
Authorized User
 
Join Date: Apr 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank u very much jomet..

 
Old March 19th, 2008, 11:15 PM
Authorized User
 
Join Date: Apr 2007
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...



 
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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.