• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

compare value from *.txt file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to compare the value that inside *.txt file, how I can do it...
the content of *.txt just only time data, make a example:
8:00:00
9:00:00
hope every experts here can help me...thank
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve
When you say 'compare', what exactly do you mean? Do you just want to check whether or not the values are the same, or are you interested in determining by how much they differ if they are not the same? Do you need to do any time arithmetic? (I am assuming these values represent times).
Firstly, you need to read the 2 values in from the text file. Have a look at the API docs for the following classes in the java.io package:
- File
- FileReader
- BufferedReader
These will enable you to read the contents of the file into memory. From there, the equals & equalsIgnoreCase methods of the java.lang.String class will perform a simple equality check for you. If you need more than that, you could write some code to parse the times as integers and compare them that way.
Hope this helps
Michael
 
steve gan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank u, your assuming really help me....thank ^-^
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic