Here you can find the source of writeAll(Path path, String data, Charset cs)
private static void writeAll(Path path, String data, Charset cs) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.OutputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; public class Main { private static final Charset ENCODING_UTF8 = StandardCharsets.UTF_8; private static void writeAll(Path path, String data, Charset cs) throws IOException { try (OutputStream os = Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { os.write(data.getBytes(ENCODING_UTF8)); }//from ww w .j ava 2s .c om } }