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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:51:45+00:00 2026-05-15T15:51:45+00:00

What is the best way to share a file between two writer services in

  • 0

What is the best way to share a file between two “writer” services in the same application?

Edit:
Sorry I should have given more details I guess.

I have a Service that saves entries into a buffer. When the buffer gets full it writes all the entries to the file (and so on). Another Service running will come at some point and read the file (essentially copy/compress it) and then empty it.

  • 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-15T15:51:45+00:00Added an answer on May 15, 2026 at 3:51 pm

    Here is a general idea of what you can do:

    public class FileManager
    {
        private final FileWriter writer = new FileWriter("SomeFile.txt");
        private final object sync = new object();
    
        public void writeBuffer(string buffer)
        {
            synchronized(sync)
            {
                writer.write(buffer.getBytes());
            }
        }        
    
        public void copyAndCompress()
        {
            synchronized(sync)
            {
                // copy and/or compress
            }
        }
    
    }
    

    You will have to do some extra work to get it all to work safe, but this is just a basic example to give you an idea of how it looks.

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

Sidebar

Related Questions

Possible Duplicate: Best way to determine if two path reference to same file in
What is the best way to share common objects between multiple views in an
what is the best way to share different objects between some classes in a
What is the best way to share a common Partial View between applications? I've
I need to have two processes share information through a memory mapped file. One
What's the best way to copy a file from a network share to the
The best way of describing this is I have a table of people with
What is the best way to maintain upgrade scripts between versions of a product?
In Visual Studio 2008 using C#, what is the best way to share code
What's the best way to separate the different tiers of an express application, so

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.