Returns the contents of a file with the given name, if it exists.
(File dir, String name)
| 191 | |
| 192 | /** Returns the contents of a file with the given name, if it exists. */ |
| 193 | public static Optional<String> readToken(File dir, String name) throws IOException { |
| 194 | File token = new File(dir, name); |
| 195 | if (!token.isFile()) { |
| 196 | return Optional.empty(); |
| 197 | } else { |
| 198 | return Optional.of(FileUtils.readFileToString(token, StandardCharsets.UTF_8)); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /** Writes an empty file with the given name in the given directory. */ |
| 203 | public static void writeToken(File dir, String name) throws IOException { |
no outgoing calls
no test coverage detected