On 17.03.2008 23:18, Joerg Heinicke 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);
        is.close();
        os.close();
    }

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.

There was a second issue with PartInMemory. It was not possible to read the InputStream a second time except by manually calling reset() on it. It used to return the same ByteArrayInputStream instance and never reset it. Both issues (this + closing the streams) are fixed in SVN.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to