Java Text File Write writeString(String data, File file)

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

Description

Writes a String to disk.

License

Open Source License

Declaration

public static boolean writeString(String data, File file) 

Method Source Code

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

import java.io.File;

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

import java.io.PrintWriter;

public class Main {
    /**Writes a String to disk. */
    public static boolean writeString(String data, File file) {
        try {//ww  w .  ja  v a  2s  .  c om
            PrintWriter out = new PrintWriter(new FileWriter(file));
            out.print(data);
            out.close();
            return true;
        } catch (IOException e) {
            System.out.println("Problem writing String to disk!");
            e.printStackTrace();
            return false;
        }
    }
}

Related

  1. writeString(final String s, final File f)
  2. writeString(String a, String MyFilePath)
  3. writeString(String content, String path, String charset)
  4. writeString(String contents, File file)
  5. writeString(String contents, File file)
  6. writeString(String data, String file_path)
  7. writeString(String fileName, String str)
  8. writeString(String filePath, boolean append, String content, String encoding)
  9. writeString(String filePath, String content)