Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

probkem in copying a file to another directory

Tarek FathyJun 25 2013 — edited Jun 26 2013

hi

my page contains  af:inputfile.

<af:inputFile label="#{viewcontrollerBundle.SELECT_FILE}" id="if1" value="#{docbean.file}"/>

the user should use this page to browse any file in his machine and uploaded to server

I use  FileUtils.copyFileToDirectory() to copy the file to the directory. this method comes from org.apache.myfaces.trinidad.model.UploadedFile;

This is the method body

import org.apache.myfaces.trinidad.model.UploadedFile;

....

    public void uploadToServer(ActionEvent actionEvent) {

        UploadedFile myFile = (UploadedFile)this.getFile();      

            File outputFile =        

                new File("D:\\SystemsData\\ScannedFiles\\" + this.getCurrentDocId() + ".tif");

            try {

                FileUtils.copyFileToDirectory((File)myFile, outputFile);

            } catch (IOException e) {

                e.printStackTrace();

            }

at run time when I press upload button I get this error

java.lang.ClassCastException: org.apache.myfaces.trinidadinternal.config.upload.UploadedFiles$FixFilename cannot be cast to java.io.File

My Question is:

how to cast org.apache.myfaces.trinidadinternal.config.upload.UploadedFiles  to java.io.File

This post has been answered by Timo Hahn on Jun 26 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2013
Added on Jun 25 2013
2 comments
459 views