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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:53:55+00:00 2026-06-12T12:53:55+00:00

I get a file personHashMap.ser with a HashMap in it. Here’s the code how

  • 0

I get a file personHashMap.ser with a HashMap in it. Here’s the code how i create it:

String file_path = ("//releasearea/ToolReleaseArea/user/personHashMap.ser");
public void createFile(Map<String, String> newContent) {
    try{
        File file = new File(file_path);

        FileOutputStream fos=new FileOutputStream(file);
        ObjectOutputStream oos=new ObjectOutputStream(fos);

        oos.writeObject(newContent);
        oos.flush();
        oos.close();
        fos.close();

    }catch (Exception e){
        System.err.println("Error in FileWrite: " + e.getMessage());
    }

}

Now i want, when the program is running, that all five minutes update the file personHashMap.ser only with the content which changed. So the method i called:

public void updateFile(Map<String, String> newContent) {
    Map<String, String> oldLdapContent = readFile();
    if(!oldLdapContent.equals(ldapContent)){ // they arent the same, 
                                             // so i must update the file

    }   

}

But now i haven’t any ideas how i can realise that.
And is it better for the performance to update only the new content or should i clean the full file and insert the new list again?

Hope you can Help me..

EDIT:

The HashMap includes i.e street=Example Street.
But now, the new street called New Example Street. Now i must update the HashMap in the File. So i can’t just append the new content…

  • 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-06-12T12:53:56+00:00Added an answer on June 12, 2026 at 12:53 pm

    Firstly HashMap isn’t really an appropriate choice. It’s designed for in-memory usage, not serialization (though of course it can be serialized in the standard way). But if it’s just 2kb, then go ahead and write the whole thing rather than the updated data.

    Second, you seem to be overly worried about performance of this rather trivial method (for 2kb the write will take mere milliseconds). I would be worried more about consistency and concurrency issues. I suggest you look into using a lightweight database such as JavaDB or h2.

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

Sidebar

Related Questions

here is my code:(get file line num and word count) import System.IO import Data.Maybe
I use this method to get file extension, public string ReturnExtension(string fileExtension) { switch
Possible Duplicate: Get file name from URI string in C# How to extract file
At the moment i get file extension of the file like : string fileExt
Here when I get file size using stat() it gives different output, why does
I had a code that worked, here: if (isset($_GET['file']) && isset($_GET['name'])) { $file =
i have this code: string filePath = ConfigurationManager.AppSettings.Get(FILE_SAVE_PATH) + fileName; string newFilePath = ConfigurationManager.AppSettings.Get(FILE_SAVE_PATH)
how to get file size in javascript or jquery with rails here by word
Is there way to get file from windows xp command prompt? I tried to
I'm trying to get file contents, replace some parts of it using regular expressions

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.