• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you need a sorting algorithm or the whole program??
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like homework, can we see what you have so far, and maybe indicate specific parts you need help with?

thanks,
Dave.
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry about posting a personal message.Thanks for the help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!