Here you can find the source of writeFile(String path, String content, Charset encoding)
Parameter | Description |
---|---|
path | path to file |
content | content of file |
encoding | file encoding |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeFile(String path, String content, Charset encoding) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; public class Main { /**/*from w w w . j a va 2 s .c om*/ * write text to file * * @param path * path to file * @param content * content of file * @param encoding * file encoding * * @throws IOException */ public static void writeFile(String path, String content, Charset encoding) throws IOException { Files.write(Paths.get(path), content.getBytes(encoding), StandardOpenOption.CREATE); } }