Java Path File Content writeFile(final String content, final String path)

Here you can find the source of writeFile(final String content, final String path)

Description

write File

License

Open Source License

Declaration

public static void writeFile(final String content, final String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.PrintWriter;

import java.nio.file.Files;

import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

public class Main {
    public static void writeFile(final String content, final String path) {

        try {/*from w  w  w. ja va 2s.c o  m*/
            final PrintWriter writer = new PrintWriter(path);
            writer.print("");
            writer.close();
            Files.write(Paths.get(path), content.getBytes(), StandardOpenOption.CREATE);
        } catch (final IOException e) {

            e.printStackTrace();
        }
    }
}

Related

  1. saveByteArrayToFile(byte[] content, Path targetPath)
  2. saveFile(String workspacePath, byte[] content)
  3. slurpFileContent(Path path)
  4. write2File(String contents, Path outputPath)
  5. WriteContentsToFile(String planeTextFilePath, byte[] encryptedData)
  6. writeFile(Path file, String content)
  7. writeFile(Path filePath, String content)
  8. writeFile(Path path, String content)
  9. writeFile(Path path, String contents)