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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:42:31+00:00 2026-06-16T09:42:31+00:00

I am dealing with a file in Java that is used to hold serialized

  • 0

I am dealing with a file in Java that is used to hold serialized objects. In order to determine if the process that is writing to this file has timed out, I check the lastModified() method on the file and expect it to be updated each time an object is written. On Linux and Mac this works fine, but on Windows, the timestamp is not updated until the FileOutputStream is closed. I’ve also tried directly updating the timestamp using setLastModified() to no avail. From what I’ve gleaned from Google, it seems that this is known behavior with files on Windows.

My question is how can I achieve what I want on Windows? I just need to be able to determine when something was serialized. The rub is that the serialization and the monitoring are in different JVMs.

I’d prefer to find a way to keep using the timestamp approach as it works great on all other platforms, but workarounds would also be appreciated.

Thanks

  • 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-16T09:42:32+00:00Added an answer on June 16, 2026 at 9:42 am

    If you have control of the source code for the writing process why no just write/touch another file too instead?

    new File(otherFile.getParent(), "touch_file").setLastModified(Sytem.currentTimeMillis());
    

    Not sure if that work or if you need to open it and close it instead:

    new FileOutputStream(new File(otherFile.getParent(), "touch_file"))).close();
    

    By the way depending on filesystem etc on Linux the lastModifiedTime on files might only have a 1 second resolution and precision.

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

Sidebar

Related Questions

I'm dealing with data that has been sampled using Java HtmlUnit. The webpage used
When dealing with a single file, I'm used to: /blah do some work n
I'm dealing with a program that reads in items from a .csv file, and
I am having an issue dealing with the notation used in a JSON file
I'm writing a windows service that might delete a file at some point. Because
I'm writing a Risk-like board game in java. A feature is that players can
Currently I am dealing with a web application which uses a txt file as
First days dealing with Perl and blocked already :) Here's the situation: a file
Dealing with Java - which the option you prefer in the most cases -
I'm working on a Java program that programmatically converts .doc- and .docx-files to pdf.

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.