MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / save

Method save

ij/src/main/java/ij/plugin/frame/Editor.java:512–542  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

510 }
511
512 @AstroImageJ(reason = "Add save listener", modified = true)
513 void save() {
514 if (path==null) {
515 saveAs();
516 return;
517 }
518 File f = new File(path);
519 if (f.exists() && !f.canWrite()) {
520 IJ.showMessage("Editor", "Unable to save because file is write-protected. \n \n" + path);
521 return;
522 }
523 String text = ta.getText();
524 char[] chars = new char[text.length()];
525 text.getChars(0, text.length(), chars, 0);
526 try {
527 BufferedReader br = new BufferedReader(new CharArrayReader(chars));
528 BufferedWriter bw = new BufferedWriter(new FileWriter(path));
529 while (true) {
530 String s = br.readLine();
531 if (s==null) break;
532 bw.write(s, 0, s.length());
533 bw.newLine();
534 }
535 bw.close();
536 IJ.showStatus(text.length()+" chars saved to " + path);
537 changes = false;
538
539 saveListeners.forEach(Runnable::run);
540 } catch
541 (IOException e) {}
542 }
543
544 void compileAndRun() {
545 if (path==null)

Callers 4

compileAndRunMethod · 0.95
actionPerformedMethod · 0.95
closeMethod · 0.95
saveAsMethod · 0.95

Calls 11

saveAsMethod · 0.95
showMessageMethod · 0.95
showStatusMethod · 0.95
getCharsMethod · 0.80
forEachMethod · 0.80
lengthMethod · 0.65
writeMethod · 0.65
closeMethod · 0.65
existsMethod · 0.45
getTextMethod · 0.45
readLineMethod · 0.45

Tested by

no test coverage detected