Here you can find the source of write(Path path, Iterable extends CharSequence> lines, Charset cs, OpenOption... options)
public static Path write(Path path, Iterable<? extends CharSequence> lines, Charset cs, OpenOption... options)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; import java.util.Arrays; public class Main { public static Path write(Path path, Iterable<? extends CharSequence> lines, Charset cs, OpenOption... options) { try {//from w w w. j ava 2 s . c o m return Files.write(path, lines, cs, options); } catch (IOException e) { throw new RuntimeException(e); } } public static Path write(Path path, Iterable<? extends CharSequence> lines, OpenOption... options) { return write(path, lines, StandardCharsets.UTF_8, options); } public static Path write(Path path, String line, Charset cs, OpenOption... options) { try { return Files.write(path, Arrays.asList(line), cs, options); } catch (IOException e) { throw new RuntimeException(e); } } public static Path write(Path path, String line, OpenOption... options) { return write(path, Arrays.asList(line), StandardCharsets.UTF_8, options); } public static Path write(Path path, byte[] bytes, OpenOption... options) { try { return Files.write(path, bytes, options); } catch (IOException e) { throw new RuntimeException(e); } } }