List of utility methods to do Path File Write nio
void | write(Object obj, String filePath) write Path path = Paths.get(filePath); try (ObjectOutputStream output = new ObjectOutputStream(Files.newOutputStream(path))) { output.writeObject(obj); |
void | write(Path p) write try { Files.write(p, BODY, StandardOpenOption.CREATE, StandardOpenOption.WRITE); } catch (IOException ex) { throw new UncheckedIOException(ex); |
void | write(Path p, String s) Writes the specified string to a file. try (BufferedWriter writer = Files.newBufferedWriter(p, Charset.forName("UTF-8"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { writer.write(s, 0, s.length()); |
void | write(Path path, String string) write PrintWriter out = null; try { out = new PrintWriter(Files.newOutputStream(path)); out.write(string); } finally { if (out != null) { out.close(); |
Process | writeAudio(String source, String writePath) write Audio String command = "\"" + WRITER_PATH + "\" \"" + source + "\" " + writePath + ""; Process process = null; try { process = Runtime.getRuntime().exec(command); printErrorStream(process); } catch (IOException e) { e.printStackTrace(); return process; |
boolean | writeEndStringInFile(Path path, String s) write End String In File FileWriter writer; try { writer = new FileWriter(path.toFile(), true); writer.write(s + "\n"); writer.close(); return true; } catch (IOException e) { e.printStackTrace(); ... |
void | writeFile(String filePath, String text) Writes a string to the specified file using the default encoding. writeFile(filePath, text, null); |
void | writeFile(String path, String output) write File Writer writer = new OutputStreamWriter(new FileOutputStream(path), UTF8); try { writer.write(output); } finally { writer.close(); |
void | writeFile(String payload, Path balOutPath) Method is responsible of writing the bal string payload to .bal file. PrintWriter writer = new PrintWriter(balOutPath.toFile(), "UTF-8"); writer.print(payload); writer.close(); |
void | writeFileToArchive(final ZipOutputStream zos, final Path baseSrcPath, final Path filePath) write File To Archive final byte[] buffer = new byte[1024]; final String zipPath = baseSrcPath.resolve(extractLanguageRelativePath(filePath)).toString(); final ZipEntry ze = new ZipEntry(zipPath); zos.putNextEntry(ze); try (InputStream in = Files.newInputStream(filePath);) { int len; while ((len = in.read(buffer)) > 0) { zos.write(buffer, 0, len); ... |