This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Accessing a file in the middle of creating it. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Accessing a file in the middle of creating it." Watch "Accessing a file in the middle of creating it." New topic
Author

Accessing a file in the middle of creating it.

Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
I have a basic console-based JAVA program that creates a ZIP file in a HTTP folder for my clients to download.
My question is what's going to happen when in the middle of creating the zip file, my clients try to access the ZIP file. Will they get incomplete file?

Thanks in advance for all the advice.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

Ummmm... yes?

If this is a concern, give the file a temporary name (WORKING.TMP) while you're writing it, and rename it to WHATEVER.ZIP when you're done.


[Jess in Action][AskingGoodQuestions]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35443
    
    9
Well, they can't get the complete file if it isn't even there yet, now can they

That begs the question why you would allow clients to access a file that hasn't been created yet?


Android appsImageJ pluginsJava web charts
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
It's a JAVA program that will create a new zip file every 5 minutes.

My concern is not on the first iteration, but on the next iterations. The old zip file would be there. It could happen that the program is rewriting the zip file and then in the middle of that, my clients are accessing the zip file. This could lead to problem, right?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a file in the middle of creating it.
 
Similar Threads
How to I know the my URLyBird version?
Could you unzip a file with a java program
Accessing a zip file through a JSP page.
Accessing a file in the middle of creating it.
Servlet creating zip file for download