Java Text File Write writeStringToFile(File outFile, String s)

Here you can find the source of writeStringToFile(File outFile, String s)

Description

write String To File

License

Open Source License

Declaration

public static void writeStringToFile(File outFile, String s) throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

public class Main {
    public static void writeStringToFile(File outFile, String s) throws IOException {
        OutputStreamWriter writer = null;
        try {//w  w  w.ja  v  a 2s .  c  o  m
            outFile.getParentFile().mkdirs();
            final OutputStream out = new FileOutputStream(outFile);
            writer = new OutputStreamWriter(out, "UTF-8");
            writer.write(s, 0, s.length());
            //      System.out.println("wrote " + outFile);
        } finally {
            try {
                writer.close();
            } catch (final Exception ignored) {
            }
        }
    }
}

Related

  1. writeStringToFile(File file, String text)
  2. writeStringToFile(File file, String text)
  3. writeStringToFile(File file, String text, boolean append)
  4. writeStringToFile(File file, String xml)
  5. writeStringToFile(File outf, String str)
  6. writeStringToFile(File p_out, String p_str)
  7. writeStringToFile(File pFile, String pString)
  8. writeStringToFile(final File file, final String data)
  9. writeStringToFile(final File file, final String data)