Java Text File Write nio writeTo(File file, String content)

Here you can find the source of writeTo(File file, String content)

Description

write To

License

Open Source License

Declaration

public static void writeTo(File file, String content) throws IOException 

Method Source Code


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

import java.util.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

public class Main {
    public static void writeTo(Path path, String content) throws IOException {
        //not intended for writing in large files.
        //Files.write(path, content.getBytes(Charset.defaultCharset()), StandardOpenOption.WRITE);
        Files.write(path, Arrays.asList(content), Charset.defaultCharset(), StandardOpenOption.WRITE);
    }//from  ww  w. j a v a  2 s  .c o m

    public static void writeTo(File file, String content) throws IOException {
        Path path = file.toPath();
        writeTo(path, content);
    }
}

Related

  1. writeStringToFile(File file, String text)
  2. writeStringToFile(final File file, final String content)
  3. writeStringToFile(String s, File f)
  4. writeTextFile(final File file, final String text)
  5. writeTextFile(String file, String articleContent)
  6. writeToFile(File file, String content)
  7. writeToFile(File file, String str)
  8. writeToFile(final File file, final String data)
  9. writeToFile(String content, String fileName)