Java UTF File Write writeToFile(String outputFile, String contents)

Here you can find the source of writeToFile(String outputFile, String contents)

Description

write To File

License

Open Source License

Declaration

public static void writeToFile(String outputFile, String contents) 

Method Source Code

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

import java.io.IOException;

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

public class Main {
    public static void writeToFile(String outputFile, String contents) {
        writeToFile(Paths.get(outputFile), contents);
    }/*from   w  w  w  . j a  v a 2s. c om*/

    public static void writeToFile(Path path, String contents) {
        try {
            Files.write(path, contents.getBytes());
        } catch (IOException e) {
            throw new UnsupportedOperationException("Failed to write to file '" + path + "'", e);
        }
    }
}

Related

  1. writeFile(byte[] data, String outfile)
  2. writeFile(String fileName, ArrayList data, String outputFolder)
  3. writeFileUTF(String nom)
  4. writeStringAsUTFByteArrayToDataOutput(final DataOutput out, final String str)
  5. writeToFile(File outputFile, String content)
  6. writeToFile(String outputFilePath, String generated)
  7. writeUTF8(DataOutput buf, String value)
  8. writeUTF8(final String filePath, final String content)
  9. writeUTF8(OutputStream out, String str)