Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:01:01+00:00 2026-05-31T12:01:01+00:00

The problem: I need to delete a reservation. The user gives me the hour

  • 0

The problem: I need to delete a reservation. The user gives me the hour of the reservation trough a SimpleInOutDialog. Then I search with a buffered reader if the file contains that hour.

What I need to do , is delete that line with the hour and 2 lines beneath it because there are the data of the reservation. Here’s and example of the txtFile:

10:00
Niel Butaye
1
09:00
Tom Mullue
2

So I look for 10:00 and then 10:00 , Niel Butaye and 1 need to be deleted.
The code that I already have is:

public void setAnnulation() {
        //make SimpleInOutDialog      
                SimpleInOutDialog  input = new SimpleInOutDialog("Delete reservation");
                reservation= input.readString("Give the hour (hh:mm)");
            try{

            BufferedReader br = new BufferedReader(new FileReader("L:\\Documents/Informatica/6de jaar/GIP/Reservations.txt"));
            HashSet<String> hs = new HashSet<String>();
            int i = 0;
            while ((line = br.readLine()) != null)
            {
                i++;
                hs.add(br.readLine());

            }
            if(hs.contains(reservation)){
                //klant bestaat
             input.showString("The Reservation is being deleted", "");...}





            }catch (Exception e){//Catch wanneer er errors zijn
                System.err.println("Error: " + e.getMessage());}


    }

Where the “…” needs to come the code. Any help ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:01:02+00:00Added an answer on May 31, 2026 at 12:01 pm

    Your approach is foul. Try to handle the file sequentially. Remember that you need to write it anyway so try this:

    (open file for reading, open new file for writing)

    1. readLine -> String variable
    2. if readLine is your reservation read the next two lines without doing anything.
    3. if not 2) then write the line to the new file.
    4. flush new file and close both.
    5. delete old file and move new one to old name.

    done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I need to write/read objects from a file.This because I need to write/read
Problem: I need to get a random element for a container and also delete
I need to delete all user info and recreate it. The code i use
To solve some problem I need to compute a variant of the pascal's triangle
I faced a problem - I need to use a macro value both as
I have problem i need to convert from my Array structure to std::vector<int> ...
i got some problem and need help .. my plan : 1. get ip
I have the following problem: I need to use XSLFO to generate a 2-column
I have the next problem: I need to process only 1 request at a
I've run in to a problem and need your guidance. Basically i managed to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.