You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jacky <ja...@hotmail.com> on 2006/01/10 09:44:23 UTC

[fileupload] upload file with error encoding

hi,
linux redhat7.3 j2sdk1.4.2 Tomcat4.1.30, common-fileupload1.0

        String docDestRelativePath = getPath(); //getPath() will generate the relative path dynamicly
        String docDestAbsPath = getServletContext().getRealPath(docDestRelativePath);
        File docDestAbsPathFile = new File(docDestAbsPath);

        String relativePath = "test/4867.txt";
        String path = getServletContext().getRealPath(relativePath) ;
        File pathFile = new File(path);

        abstractItem.write(pathFile);               //line 1,
        abstractItem.write(docDestAbsPathFile);     //line 2

line 1 write the file with right encoding, but the line 2 write the file with funny txt. 
When using System.getProperty("file.encode") before line 1, after line 1 and after line 2, all print utf-8. I think it maybe the encoding of tomcat container because the encoding of my system is iso8859_15.

I don't know why this happens. What can i do to make the line 1 work?  Thanks for your help!

     Best Regards.