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

Method open

ij/src/main/java/ij/plugin/frame/Editor.java:454–483  ·  view source on GitHub ↗

Opens a file and replaces the text (if any) by the contents of the file.

(String dir, String name)

Source from the content-addressed store, hash-verified

452
453 /** Opens a file and replaces the text (if any) by the contents of the file. */
454 public void open(String dir, String name) {
455 path = dir+name;
456 File file = new File(path);
457 if (!file.exists()) {
458 IJ.error("File not found: "+path);
459 return;
460 }
461 try {
462 StringBuffer sb = new StringBuffer(5000);
463 BufferedReader r = new BufferedReader(new FileReader(file));
464 while (true) {
465 String s=r.readLine();
466 if (s==null)
467 break;
468 else
469 sb.append(s+"\n");
470 }
471 r.close();
472 if (ta!=null && ta.getText().length()>0) {
473 ta.setText(""); //delete previous contents (if any)
474 eventCount = 0;
475 }
476 create(name, new String(sb));
477 changes = false;
478 }
479 catch (Exception e) {
480 IJ.handleException(e);
481 return;
482 }
483 }
484
485 public String getText() {
486 if (ta==null)

Callers 4

editMethod · 0.95
revertMethod · 0.95
openMethod · 0.95
editObservatoriesMethod · 0.95

Calls 10

errorMethod · 0.95
createMethod · 0.95
handleExceptionMethod · 0.95
appendMethod · 0.65
closeMethod · 0.65
lengthMethod · 0.65
existsMethod · 0.45
readLineMethod · 0.45
getTextMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected