List of utility methods to do Path Create nio
void | createDirectory(Path path) create Directory if (Files.notExists(path)) {
Files.createDirectory(path);
|
void | createDirIfDoesNotExist(String websitesDirPath) create Dir If Does Not Exist Path directoryPath = Paths.get(websitesDirPath); if (!Files.exists(directoryPath)) { try { Files.createDirectory(directoryPath); } catch (IOException e) { e.printStackTrace(); |
void | createEmptyResourceFile(Path path) Creates an empty resource file at the given path, assuming the file does not exist already if (path.toFile().exists()) { return; try { Files.createFile(path); Files.write(path, EMPTY_RESOURCE_FILE.getBytes()); } catch (IOException e) { e.printStackTrace(); ... |
void | createFile(File root, String path, String filename, String value) create File File dir = new File(root, path); if (!dir.exists()) { if (!dir.mkdirs()) { throw new IOException("Failed to create directories " + dir.toString()); File file = new File(dir, filename); if (!file.createNewFile()) { ... |
void | createFile(final Path file, final String line) create File try (final PrintWriter pw = new PrintWriter(Files.newBufferedWriter(file, StandardCharsets.UTF_8), true)) { pw.println(line); |
void | createFile(Path filePath, byte[] content) Creates a file with the specified content. try (OutputStream output = Files.newOutputStream(filePath)) {
output.write(content);
output.flush();
|
void | createFile(Path p) create File try { PrintWriter writer = new PrintWriter(p.toString(), "UTF-8"); writer.println(p.toString()); writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); ... |
File | createFile(Path path) Create a file at the given absolute or relative path. File file = path.toAbsolutePath().toFile(); if (file.exists() && file.canRead() && file.canWrite()) { if (file.isFile()) return file; throw new IllegalStateException("Expecting '" + path + "' to be a file but found a directory"); file.getParentFile().mkdirs(); return file; ... |
void | createFile(Path path) create File try { Files.createFile(path); } catch (FileAlreadyExistsException e) { } catch (IOException e) { throw new RuntimeException(e); |
void | createFile(Path path) Creates a new and empty file. Files.createFile(path); |