Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

java help urgently needed

Options
  • 27-02-2005 6:08pm
    #1
    Registered Users Posts: 830 ✭✭✭


    hey ill just explain the problem that im having. what i have is a text file like the one below....

    9:00-9:30
    9:30-10:00
    11:00-12:00
    12:00-13:00
    13:00-15:00
    15:00-16:00
    16:00-17:00

    i also have a similar text file but the times are slightly different. what i want to be able to do is look at the difference between the two files to see what time is not featured in them, e.g 10:00-11:00 above. i have no clue in what way to go about this problem and any help would be greatly appreciated, cheers.


Comments

  • Registered Users Posts: 261 ✭✭HaVoC


    Regular expressions i'd say have a look at this tutorial regex


  • Registered Users Posts: 830 ✭✭✭mrpink6789


    cheers man ill have a look at them.


  • Registered Users Posts: 830 ✭✭✭mrpink6789


    sorry i thought i could understand the regular expressions but i am still a bit lost. just dont know what way to go about comparing my times?


  • Registered Users Posts: 333 ✭✭s4dd


    you could create a string tokenizer for each line that uses the "-" tag as a deliminator...

    look up java.util.StringTokenizer. That's one way of doing it that would work perfect..


  • Registered Users Posts: 1,184 ✭✭✭causal


    mrpink6789 wrote:
    i also have a similar text file but the times are slightly different. what i want to be able to do is look at the difference between the two files to see what time is not featured in them

    Is it the difference between the two files you want, or is it what time is missing from each file? Can you be a lot more specific.

    In the simplest case of the former just read each line from each file and compare the two using this.compareTo(that).

    Otherwise you've a bit more logic to build in - note that if you're looking for missing time slots then it's the end of one string and the start of the next that you'll be comparing.
    e.g. A-B, B-C, D-E -> in this case C # D, so C-D is the missing element.

    causal


  • Advertisement
  • Registered Users Posts: 830 ✭✭✭mrpink6789


    Hey i would be comparing two files so that if one has 9-9.30 and the other has 9-10 the whole 9-10 slot would be taken so it could not be used.


  • Registered Users Posts: 6,240 ✭✭✭hussey


    mrpink6789 wrote:
    Hey i would be comparing two files so that if one has 9-9.30 and the other has 9-10 the whole 9-10 slot would be taken so it could not be used.

    sounds like some kind of booking form - say a room booking or something

    assuming all the text in the files are correct format

    ....

    firstly come up with a timetable (a generic one) - this will be the equilivalant to a blank Time table (call it BTT)

    read in the txt file and find out the times
    when you establish a time from the file
    look it up on the BTT if its free - use it (or what ever you want to do with it)
    do the same for each file etc


Advertisement