Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8313777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:36:27+00:00 2026-06-08T20:36:27+00:00

Hello I have problem with followed function that should save forwarded bufferedImage on disk.

  • 0

Hello I have problem with followed function that should save forwarded bufferedImage on disk. When I run this code there no exception throwed no problems, BufferedImage is transfered to ImageIO.write(img, ext ,fileToSave) file was created, ext is correct but there no image on my disk! After hours i dont have idea what can go wrong. Maybe permission? But i have it to read/write on disk.

  public boolean SaveImage(BufferedImage img)
{
    JFileChooser FC=new JFileChooser("C:/");
    FC.addChoosableFileFilter(new jpgSaveFilter());
    FC.addChoosableFileFilter(new jpegSaveFilter());
    FC.addChoosableFileFilter(new PngSaveFilter());
    FC.addChoosableFileFilter(new gifSaveFilter());
    FC.addChoosableFileFilter(new BMPSaveFilter());
    FC.addChoosableFileFilter(new wbmpSaveFilter()); 

    int retrival=FC.showSaveDialog(null);

    if (retrival == FC.APPROVE_OPTION) 
       {

            String ext="";

            String extension=FC.getFileFilter().getDescription();

           if(extension.equals("*.jpg,*.JPG"))
          { 
              ext=".jpg";
          }
          if(extension.equals("*.png,*.PNG"))
          { 
              ext=".png";
          }
          if(extension.equals("*.gif,*.GIF"))
          { 
              ext=".gif";
          }
          if(extension.equals("*.wbmp,*.WBMP"))
          { 
              ext=".wbmp";
          }
          if(extension.equals("*.jpeg,*.JPEG"))
          { 
              ext=".jpeg";
          }
          if(extension.equals("*.bmp,*.BMP"))
          { 
              ext=".bmp";
          }

          File fileToSave = FC.getSelectedFile();
          try{
              ImageIO.write(img, ext ,fileToSave);

          }
          catch (IOException e) {
                e.printStackTrace();
            }
          catch(Exception ex)
          {
              System.out.println(ex.getMessage());
              return false;
          }
          return true;
       }
    return false;
}

Thanks for help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:36:29+00:00Added an answer on June 8, 2026 at 8:36 pm

    The problem is your specifying the file format as the ext

    Effectively your saying

    ImageIO.write(img, ".jpg" ,fileToSave)
    

    You need to supply it so it evaluates to

    ImageIO.write(img, "jpg" ,fileToSave)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem when trying to run hello world program using android SDK.
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello i have problem with putting logs using multithreading, my function loks like this
Hello i have a problem with this line of code: Last Visted On :
Hello i have the following problem, I record a video using red5 like this:
Hello again everyone, This time I have a problem with Intent & Extras. here's
This should be simple. Yet, it's giving me Hell. Problem I have compiled the
Hello I have a problem with this http://jsfiddle.net/E7dGA/1/ When the script starts and you
Hello I have a problem while trying to run a makefile. I change the
I have a compiling problem. I followed tutorial about Hello world program for Android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.