--- profiler/src/org/netbeans/modules/profiler/Bundle.properties +++ profiler/src/org/netbeans/modules/profiler/Bundle.properties @@ -106,6 +106,7 @@ ExportAction_OverwriteFileCaption=Overwrite Existing File ExportAction_OverwriteFileMsg=File {0} already exists.

Do you want to replace it? ExportAction_CannotOverwriteFileMsg=File {0} cannot be replaced. Check permissions. +ExportAction_FileWriteErrorMsg=Unable to write {0} file ExportAction_ExportDialogTitle=Select File or Directory ExportAction_ExportDialogButton=Export ExportAction_ExportDialogCSVFilter=CSV File (*.csv) --- profiler/src/org/netbeans/modules/profiler/SaveViewAction.java +++ profiler/src/org/netbeans/modules/profiler/SaveViewAction.java @@ -54,11 +54,14 @@ import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.text.MessageFormat; import javax.imageio.ImageIO; +import javax.imageio.stream.FileImageOutputStream; import javax.swing.*; import javax.swing.filechooser.FileFilter; +import org.openide.DialogDisplayer; class SaveViewAction extends AbstractAction { @@ -207,12 +210,20 @@ pHandle.start(); BufferedImage img = (bImage == null) ? viewProvider.getViewImage(visibleArea) : bImage; - if (img != null) ImageIO.write(img, "png", file); //NOI18N - } catch (IOException ex) { - //ex.printStackTrace(); + FileImageOutputStream stream = new FileImageOutputStream( file ); + if (img != null) ImageIO.write(img, "png", stream); //NOI18N } catch (OutOfMemoryError e) { NetBeansProfiler.getDefaultNB().displayError(OOME_SAVING_MSG); - } finally { + } catch (FileNotFoundException fnfex) { + NotifyDescriptor descriptor = new NotifyDescriptor.Message( + NbBundle.getMessage (SaveViewAction.class, + "ExportAction_FileWriteErrorMsg", file.getAbsolutePath ()) , + NotifyDescriptor.ERROR_MESSAGE ); + DialogDisplayer.getDefault().notify( descriptor ); + } catch (IOException ex) { + //ex.printStackTrace(); + } + finally { if (bImage != null) { bImage.flush(); }