This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes  validation specifications for sorting date,integer,string... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark " validation specifications for sorting date,integer,string..." Watch " validation specifications for sorting date,integer,string..." New topic
Author

validation specifications for sorting date,integer,string...

vasantkr kr
Greenhorn

Joined: Jan 25, 2006
Posts: 4
Input File:
sss.java 88
sss.java 89.5
sss.html 99.5
sss.java 11/13/2005
sss.html 02/22/2005
sss.html 02/23/2005
sss.java 89
.
.
.
// n inputs

Output File:
1.Sorted List for sss.java:
88
89
2.Sorted Decimal List for sss.java
89.5
3.Sorted Date list for sss.java
13-Nov-2005
23-feb-2005

1.Sorted List for sss.html:
88
89
2.Sorted Decimal List for sss.html
99.5
3.Sorted Date list for sss.html
22-feb-2005


The requirement is to read the data line by line as given in the input file for 'n' entries and then present the output by sorting.Output should be similar to the one shown in 'output file'.
Here is what i have done so far.......


//After this i need help to sort the values so that i can present them in the format specified in the output file.
[ January 25, 2006: Message edited by: vasantkr kr ]
Hilton Meyer
Greenhorn

Joined: Nov 13, 2003
Posts: 17
do you need a sorting algorithm or the whole program??


Keep it Tidy
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Sounds like homework, can we see what you have so far, and maybe indicate specific parts you need help with?

thanks,
Dave.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12963
    
    3

Here are some links.

To learn how to read a file in Java, see the I/O tutorial. You can use java.io.BufferedReader to read a file line by line, or java.util.Scanner if you are using Java version 1.5.

You will need to store the data that the program reads in a list or array. See the Collections tutorial to learn how to use the Java Collections API.

You can sort a List in Java by using the one of the sort(...) methods in class java.util.Collections. See the API documentation.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12963
    
    3

vasantkr kr,

Why did you respond to my post with a private message instead of just posting your question here?
I have finished reading the file and split the contents(i.e the string and the number).
From here i have to sort the contents.
The problem comes when am trying to read the date and to print it in the format specified in the output file.

Please explain exactly what "the problem" is. Did you write some code? Does it compile or not? Do you get an error message? If yes, copy & paste the error message here.

You can parse and format dates using java.text.SimpleDateFormat (see the API documentation).
vasantkr kr
Greenhorn

Joined: Jan 25, 2006
Posts: 4
sorry about posting a personal message.Thanks for the help.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: validation specifications for sorting date,integer,string...
 
Similar Threads
Phonebook
need urgent help in a sorting program
PrintWriter please help
Problem in file transfer
Files from a directory is not being recognized