Java Text File Write writeStringToFile(String fileName, String src)

Here you can find the source of writeStringToFile(String fileName, String src)

Description

write String To File

License

Open Source License

Declaration

public static boolean writeStringToFile(String fileName, String src) 

Method Source Code

//package com.java2s;

import java.io.FileWriter;
import java.io.IOException;

public class Main {

    public static boolean writeStringToFile(String fileName, String src) {
        if (src == null) {
            src = "";

        }/*from  ww w .j a v  a 2s. co m*/
        boolean isOk = true;
        FileWriter out = null;
        try {
            out = new FileWriter(fileName);
            out.write(src);
            out.close();
        } catch (IOException e) {
            isOk = false;
            e.printStackTrace();
        } catch (Exception e) {
            isOk = false;
            e.printStackTrace();
        } finally {
            out = null;
        }
        return isOk;
    }
}

Related

  1. writeStringToFile(String f, String s, boolean append)
  2. writeStringToFile(String file, String data, boolean append)
  3. writeStringToFile(String file, String str, boolean append, boolean newLine)
  4. writeStringToFile(String fileName, String content)
  5. writeStringToFile(String filename, String content)
  6. writeStringToFile(String filename, String str)
  7. writeStringToFile(String fileName, String str, boolean isAppend)
  8. writeStringToFile(String filename, String string)
  9. writeStringToFile(String filename, String string, boolean overwrite)