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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:17:29+00:00 2026-05-29T10:17:29+00:00

I am building a Java application to process files on a local FS (NTFS,

  • 0

I am building a Java application to process files on a local FS (NTFS, but a solution that would allow an easy extension to Linux filesystems in future would be nice). The problem is that a single file cannot be processed more than once in case of two instances (processes) of my application running simultaneously.

Seems like I need to lock each file before processing it somehow. The application does not use a database and using one just for the purpose of locking does not seem convenient.

So I was thinking about appending a postfix to the filename. The question is, how (if it’s possible) to ask if a filename ends with a postfix and then append the postfix atomically.

Other tricks to achieve what I need are also appreciated.

  • 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-29T10:17:30+00:00Added an answer on May 29, 2026 at 10:17 am

    You can perhaps take an advantage of the fact that file rename operation is atomic on most file systems. Your logic could be like this:

    1. Get file list, for each file:
    2. Try to rename the file
    3. If rename succeed – work on the file
    4. If rename fails – don’t work on the file
    5. Got to 2
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a Java application that will allow our users to load a list
We're in the process of building an internal, Java-based RESTful web services application that
I'm currently working on a project that is building a java-based desktop application to
I'm building a Java application with a Swing GUI and a task that takes
I'm building a java application that gets the mac addresses of a user and
I am currently building a java-servlet-based web application that should offer its service to
I'm building a Java application (using Ant with build.xml and build.property files). Now I'd
Currently I'm building my Java Web Application on Google AppEngine (GAE), but due to
I am building a Java EE application using NetBeans 7.1.1. I would prefer to
I'm building a java application which works in a LAN environment, every computer on

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.