Java Text File Write writeStringToFile(final File file, final String data)

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

Description

write String To File

License

Open Source License

Declaration

public static void writeStringToFile(final File file, final String data) 

Method Source Code

//package com.java2s;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class Main {
    public static void writeStringToFile(final File file, final String data) {
        try {/*from www. ja  v a  2s  . c  om*/
            final OutputStream outputStream = new BufferedOutputStream(
                    new FileOutputStream(file, false));
            outputStream.write(data.getBytes("UTF-8"));
            outputStream.close();
        } catch (IOException e) {
            throw new RuntimeException(
                    "could not write file for debug cache", e);
        }
    }
}

Related

  1. writeStringToFile(File file, String xml)
  2. writeStringToFile(File outf, String str)
  3. writeStringToFile(File outFile, String s)
  4. writeStringToFile(File p_out, String p_str)
  5. writeStringToFile(File pFile, String pString)
  6. writeStringToFile(final File file, final String data)
  7. writeStringToFile(final String path, final String output)
  8. writeStringToFile(final String string, final File file)
  9. writeStringToFile(final String text, final File filePath)