cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <>
Subject Re: upload widget
Date Tue, 18 Mar 2008 03:18:30 GMT
On 17.03.2008 10:26, Felix Knecht wrote:

>>    part.copyToFile("new.pdf") ;
> I don't think that 'part' implements a the function 'copyToFile' (at 
> least I haven't found it).

It is, but not really in a useful way:

     public void copyToFile(String filename) throws IOException {
         InputStream is = getInputStream();
         OutputStream os = new FileOutputStream(filename);
         IOUtils.copy(is, os);

So the file is created relative to the JVM's base directory which is for 
Tomcat the bin directory in CATALINA_HOME (when started via the batch 
files in that directory).

I'd rather recommend to use absolute filenames or copyToSource(Source) 
and resolve the path you want to write to beforehands.

Also the above is a rather buggy implementation, there is no guarantee 
the streams are closed.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message