Solved

Java file write in a transaction

Posted on 2013-01-28
2
291 Views
Last Modified: 2013-02-11
Hello team,

I have a Java application which which needs to write a file to a filesystem destination completely before being read by anything.  Wouldn't this be easily achieved by running the file writing logic inside a transaction?  

This should not allow any user or application to see the file until writing is 100% complete.  Am I correct in this idea?
0
Comment
Question by:Phil5780
2 Comments
 
LVL 4

Accepted Solution

by:
tvedtem earned 500 total points
ID: 38829549
What do you mean by 'transaction' ?  
That's usually a term I'd use when dealing with databases.

One way of working with files is to write to a temporary file, and when complete (and successful), rename/move the file.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38830442
I have a Java application which which needs to write a file to a filesystem destination completely before being read by anything.
What is 'being read'?

Don't describe the code you think you need or the steps. Describe the GOAL
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now