MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / readFromFile

Method readFromFile

src/main/java/fieldbox/io/IO.java:120–132  ·  view source on GitHub ↗
(File f)

Source from the content-addressed store, hash-verified

118 this.defaultDirectory = new File(defaultDirectory).getCanonicalPath();
119 if (!new File(defaultDirectory).exists()) new File(defaultDirectory).mkdir();
120 }
121
122
123 static public String readFromFile(File f) {
124 try {
125 return Files.readAllLines(sanitizeName(f).toPath(), StandardCharsets.ISO_8859_1)
126 .stream()
127 .reduce((a, b) -> a + "\n" + b).orElse("");
128 } catch (IOException e) {
129 e.printStackTrace();
130 } catch (InvalidPathException e) {
131 System.err.println(" illegal character in filename ? " + sanitizeName(f).toPath() + ", continuing on");
132 }
133
134 return "";
135 }

Callers 4

dropMethod · 0.95
readDocumentMethod · 0.95
fromExternalMethod · 0.95
loadSingleBoxMethod · 0.95

Calls 3

sanitizeNameMethod · 0.95
streamMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected