In general, in this type of case, I recommend doing something like: (pseudo
code)
return new DataHandler(new FileDataSource(tempFile)) {
public void writeTo(OutputStream out) {
super.writeTo(out);
tempFile.delete();
}
};
or similar. Basically, when the datahandler is done being written out,
delete the file.
Dan
On Tuesday 02 December 2008 1:14:40 pm Daniel Lipofsky wrote:
> I have a web-service that is returning a stream like this:
>
> <xsd:element name="objects" type="xsd:base64Binary"
> xmime:expectedContentTypes="application/octet-stream"/>
>
> My implementation method works by creating a
> temporary file and the returning like
>
> return new DataHandler(new FileDataSource(tempFile));
>
> My understanding is that this is asynchronous.
> So how can I trigger a deletion of this file
> when the streaming is done?
>
> I am already calling tempFile.deleteOnExit() but it
> could be months or years before the JVM actually exits,
> and I want to delete it sooner.
>
> Thanks,
> Dan
--
Daniel Kulp
[EMAIL PROTECTED]
http://dankulp.com/blog