Java Path File Write nio saveToFile(String path, byte[] text)

Here you can find the source of saveToFile(String path, byte[] text)

Description

save To File

License

Apache License

Declaration

public static void saveToFile(String path, byte[] text) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Paths;

public class Main {
    public static void saveToFile(String path, byte[] text) {
        try {//from  w ww . j  av  a2  s.com
            Files.write(Paths.get(path), text);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void saveToFile(String path, String text) {
        System.out.println("FileUtil.saveToFile()");
        try {
            Files.write(Paths.get(path), text.getBytes("UTF-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. save(Object o, String path)
  2. saveFile(String path, String text)
  3. saveHeaders(Path path, ArrayList headers)
  4. saveProperties(Path filePath, Properties prop)
  5. saveTo(String path, InputStream in)
  6. setPosixPermissions(String path, boolean ownerRead, boolean ownerWrite, boolean ownerExecute, boolean groupRead, boolean groupWrite, boolean groupExecute, boolean othersRead, boolean othersWrite, boolean othersExecute)
  7. srcImageToSavePath(String src, Path saveFolder)
  8. write(List list, String outputPath)
  9. write(Object obj, String filePath)