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!

How to save image iside folder in ADF application?

User_UM8AVApr 14 2019 — edited Apr 14 2019

Dears,

in my adf application I created folder with name img and I want to save the uploaded images into this folder so I wrote the below code :

   UploadedFile myFile = (UploadedFile) valueChangeEvent.getNewValue();
    String imageDirPath = "/img/";
 
        InputStream inputStream = myFile.getInputStream();
        BufferedImage input = ImageIO.read(inputStream);
      
        File outputFile = new File(imageDirPath +var+".jpg");
        ImageIO.write(input,"PNG",outputFile);

I get error where it can't find the path of my folder img  but when I write the path like this  D:/ADF/MyApp/ViewController/public_html/img/ it work fine. So please advise what is the error in this line String imageDirPath = "/img/"; 

This post has been answered by Timo Hahn on Apr 14 2019
Jump to Answer
Comments
Post Details
Added on Apr 14 2019
1 comment
325 views