MCPcopy Index your code
hub / github.com/badvision/jace / getFileContents

Method getFileContents

src/main/java/jace/ide/Program.java:146–170  ·  view source on GitHub ↗
(File sourceFile)

Source from the content-addressed store, hash-verified

144 }
145
146 public String getFileContents(File sourceFile) {
147 if (sourceFile != null && sourceFile.exists() && sourceFile.isFile()) {
148 BufferedReader reader = null;
149 try {
150 StringBuilder input = new StringBuilder();
151 reader = new BufferedReader(new FileReader(sourceFile));
152 reader.lines().forEach((line) -> {
153 input.append(line);
154 input.append("\n");
155 });
156 return input.toString();
157 } catch (IOException ex) {
158 Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex);
159 } finally {
160 try {
161 if (reader != null) {
162 reader.close();
163 }
164 } catch (IOException ex) {
165 Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex);
166 }
167 }
168 }
169 return "";
170 }
171
172 public void save(File newTarget) {
173 FileWriter writer = null;

Callers 1

createEditorMethod · 0.95

Calls 4

closeMethod · 0.80
getNameMethod · 0.65
toStringMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected