Article View: borland.public.jbuilder.java.language
Article #8315Re: Unique file name
From: Joi Ellis [TeamB]
Date: Thu, 29 Mar 2001 23:19
Date: Thu, 29 Mar 2001 23:19
27 lines
2123 bytes
2123 bytes
se wen <se_wen@nightmail> wrote:
> .................................................................
> JCEncodeComponent.encode(JCEncodeComponent.PNG, SESChart.snapshot(), new
> File("c:/Windows/jbproject/untitled8/src/untitled8/chart.PNG"));
> .................................................................
> However, since there will be multiple users and threads at the same time
> accessing the chart method we need some method that can scan the name of the
> files in the directory (for the above example it would be 'untitled8') then
> assign a new name that does not already exist in that directory. This name
> would need to be able to be stored as a variable so that it can be passed to
> the above encoding method.
Okay. I'd probably start out using File.list() to get a list of existing
files in the directory, and manually compute what the next name would be.
However, you need to ensure this method is thread-safe so that you don't
have multiple users stomping on each others' files. If they're going to be
in separate JVMs, even that isn't enough, so you'll have to use some sort
of platform-aware locking method to control name creation.
Ick...
--
Joi Ellis (TeamB)
No direct email, please.
For best results, post on news server newsgroups.borland.com!
Newsgroup Info: http://www.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<3ac3c302_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!not-for-mailReferences:
<3ac3a412$1_1@dnews> <3ac3a833_1@dnews> <3ac3b766$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,a9c867af487cce47
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-29 16:36:05 PST
Message-ID: <3ac3c302_2@dnews>
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: Unique file name
Newsgroups: borland.public.jbuilder.java.language
References: <3ac3a412$1_1@dnews> <3ac3a833_1@dnews> <3ac3b766$1_1@dnews>
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.16-3 (i686))
NNTP-Posting-Host: 209.46.41.66
Date: 29 Mar 2001 15:19:31 -0800
X-Trace: 29 Mar 2001 15:19:31 -0800, 209.46.41.66
Lines: 27
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!not-for-mail