Java Path File Content writeToFile(String content, String filePath)

Here you can find the source of writeToFile(String content, String filePath)

Description

write To File

License

Open Source License

Declaration

public static void writeToFile(String content, String filePath) 

Method Source Code


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

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static void writeToFile(String content, String filePath) {
        Path path = Paths.get(filePath);
        try {/*from   w  w w  .j a v  a  2s .  co m*/
            Files.write(path, content.getBytes("utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeStringToFile(String content, Path targetPath)
  2. writeToBinaryFile(String filePath, byte[] binaryContent)
  3. writeToFile(Path absolutePath, byte[] content)
  4. writeToFile(Path file, String content)
  5. writeToFile(Path path, String content)
  6. writeToFile(String filePath, String content)