Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry about posting a personal message.Thanks for the help.
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic