MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / saveEditorTextTo

Method saveEditorTextTo

src/test/LoaderTest.java:357–372  ·  view source on GitHub ↗

Writes the editor text string to a file. @param target the file @return the saved file, or null if failed

(File target)

Source from the content-addressed store, hash-verified

355 * @return the saved file, or null if failed
356 */
357 private File saveEditorTextTo(File target) {
358 if (target == null)
359 return null;
360 if (!(target.getParentFile().exists() || target.getParentFile().mkdirs()))
361 return null;
362 String path = target.getAbsolutePath();
363 try {
364 BufferedWriter out = new BufferedWriter(new FileWriter(path));
365 out.write(textArea.getText());
366 out.flush();
367 out.close();
368 return target;
369 } catch (IOException ex) {
370 return null;
371 }
372 }
373
374 /**
375 * Uses a file chooser to define the zip file path.

Callers 1

prepareZipFilesMethod · 0.95

Calls 6

existsMethod · 0.80
writeMethod · 0.65
getTextMethod · 0.65
closeMethod · 0.65
getAbsolutePathMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected