Java Text File Write nio writeStringToFile(File file, String text)

Here you can find the source of writeStringToFile(File file, String text)

Description

write the given String to a the given file

License

Apache License

Parameter

Parameter Description
file a parameter
text a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static void writeStringToFile(File file, String text) throws Exception 

Method Source Code


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

import java.io.File;

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

public class Main {
    /**/*w  w  w  . j  av  a  2 s.c o  m*/
     * write the given String to a the given file
     * 
     * @param file
     * @param text
     * @throws Exception 
     */
    public static void writeStringToFile(File file, String text) throws Exception {
        Files.write(Paths.get(file.toURI()), text.getBytes());
    }
}

Related

  1. writeString(File file, String content)
  2. writeString(final File file, final String str)
  3. writeString(OutputStream buffer, String s)
  4. writeStringToFile(File file, String content, String value)
  5. writeStringToFile(File file, String string)
  6. writeStringToFile(final File file, final String content)
  7. writeStringToFile(String s, File f)
  8. writeTextFile(final File file, final String text)
  9. writeTextFile(String file, String articleContent)