• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Accessing a file in the middle of creating it.

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Smith Li
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case not even Ernests approach would work, because it would disrupt the currently active download. I'd give the files distinctive names, and tell the clients to download the latest (or alphabetically highest). That can be automated easily.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
Is there any method to check incomplete file or completed file?
I have same problem to rename incomplete file while being copy a big size file.

give me advice,
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Eung JM", please check your private messages for an important administrative matter.

Also please do not repeat a question in more than one topic, and please don;t revive old topics.
[ July 31, 2008: Message edited by: Bear Bibeault ]
 
Oh the stink of it! Smell my tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic