Java Text File Write WriteStringToFile(String fn, String dest)

Here you can find the source of WriteStringToFile(String fn, String dest)

Description

Write string to file.

License

Apache License

Parameter

Parameter Description
fn the fn
dest the dest

Declaration

public static void WriteStringToFile(String fn, String dest) 

Method Source Code

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

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    /**// ww w .  j a va  2s. co m
     * Write string to file.
     *
     * @param fn   the fn
     * @param dest the dest
     */
    public static void WriteStringToFile(String fn, String dest) {

        FileOutputStream fo = null;
        try {
            fo = new FileOutputStream(fn);
            fo.write(dest.getBytes());
            fo.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Related

  1. writeStringToFile(String fileName, String str, boolean isAppend)
  2. writeStringToFile(String filename, String string)
  3. writeStringToFile(String filename, String string, boolean overwrite)
  4. writeStringToFile(String filename, String stringToWrite)
  5. writeStringToFile(String filename, String text)
  6. writeStringToFile(String fullPath, byte[] fileBytes)
  7. writeStringToFile(String fullPath, String content)
  8. writeStringToFile(String jsonStr, File file)
  9. writeStringToFile(String macroContent, File file)