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 1113831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:54:54+00:00 2026-05-17T02:54:54+00:00

All, Considering my earlier query Stackoverflow-Post , here is what I am currently doing.

  • 0

All,

Considering my earlier query Stackoverflow-Post, here is what I am currently doing. This is a kind of flowchart:

1 > Add record to file:
a. Get the details for new record
b. Retrieve all the records from the file.
c. Compare each record retrieved with the new record details. If match found, do not add to the file, else add the new record.

2 > Search for a record in file.
a. Get the details for the record to be searched (Here only the credit card number.)
b. Retrieve all the records from the file.
c. Compare each record retrieved with the record searched for. If match found, display the details.

3 > Delete a record from the file.
a. Get the details for the record to be deleted (Here only the credit card number.)
b. Retrieve all the records from the file.
c. Compare each record retrieved with the record searched for. If match found, delete the entry from the file.

As can be seen, I am doing an IO every time for a operation. Is there any way I can optimize or improve performance for my code?

The API I am using for Add record is FileWriter , for search operation it is BufferedReader and for deleting a record is BufferedReader and PrintWriter

  • 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-17T02:54:54+00:00Added an answer on May 17, 2026 at 2:54 am

    I would also suggest you use a database but if you must use a file then an option i can suggest is Java serialization.Maintain a HashMap with Key as the credit-card number and the rest of the information wrapped in an object as the value.Each time a new records are added add the information to the hashmap and serialize the data and delete the old file.Same you can do for deletion of records and for searching its very easy since the information is in a hashmap , all you have to do is check if the key is present or not and another advantage is you don’t have to bother about the format for writing into a file and then parsing it again.

    If the number of records are large a problem that can probably occur is that you have to load the large file into memory.A solution is you can maintain a limit for the number of records per file and you can maintain a look-up with a navigable map(check this link for example).A range of credit card number’s can be stored in a certain file.The key for the look-up can be the starting range of the credit-card and the the value can the file name.

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

Sidebar

Related Questions

We're considering switching our site from Prototype to jQuery. Being all-too-familiar with Prototype, I'm
All I want is to update an ListViewItem's text whithout seeing any flickering. This
All the articles I've found via google are either obsolete or contradict one another.
All the recent VisualSVN Server posts made me want to check it out. I
All front-end developers know the pain of coding for Firefox, then viewing our then
All I know about the constraint is it's name ( SYS_C003415 ), but I
All I want is to be able to change the color of a bullet
All throughout an application wherever error messages (or other user messages) are used I
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
All of my users are a short walk down the hall, and all of

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.