Esempio n. 1
0
 /** Saves the file back to disk. */
 private void saveFile() {
   File file = getTargetFile().getFile();
   Writer writer = null;
   Cursor originalcursor = this.getOwner().getCursor();
   this.getOwner().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   try {
     CharsetEncoder encoder = getCharset().newEncoder();
     if (encoder.canEncode(textArea.getText())) {
       writer = new OutputStreamWriter(new FileOutputStream(file), getCharset());
       textArea.write(writer);
       messageBox.clear();
     } else {
       findIllegalCharacter(encoder);
     }
   } catch (FileNotFoundException fnfx) {
     // happens also if file is RO
     logger.error("FileNotFoundException saving to " + file.getPath() + ": " + fnfx.getMessage());
     messageBox.error(getLocalizer().localize("message.file-removed"));
   } catch (IOException iox) {
     logger.error("IOException saving file " + file.getPath() + ": " + iox.getMessage());
     messageBox.error(
         getLocalizer()
             .localize("message.file-processing-error", new Object[] {iox.getMessage()}));
   } finally {
     this.getOwner().setCursor(originalcursor);
     if (writer != null)
       try {
         writer.close();
       } catch (IOException iox) {
         logger.warn("IOException closing stream: " + iox.getMessage());
       }
   }
 }
 private void saveFile(String fileName) {
   try {
     FileWriter w = new FileWriter(fileName);
     area1.write(w);
     w.close();
     currentFile = fileName;
     changed = false;
     Save.setEnabled(false);
   } catch (IOException e) {
   }
 }
 private void saveFile(String fileName) {
   try {
     FileWriter w = new FileWriter(fileName);
     area.write(w);
     w.close();
     currentFile = fileName;
     setTitle(currentFile + " - CoreyTextEditor");
     changed = false;
     Save.setEnabled(false);
   } catch (IOException e) {
     // No handling done here
   }
 }