Android File Write stringToFile(String filename, String stringToWrite)

Here you can find the source of stringToFile(String filename, String stringToWrite)

Description

Saves passed string to file

License

Open Source License

Parameter

Parameter Description
filename path to file
stringToWrite string to save

Declaration

public static void stringToFile(String filename, String stringToWrite) 

Method Source Code

//package com.java2s;
//  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of

import java.io.BufferedWriter;

import java.io.FileWriter;

public class Main {
    /**//from  w  w w.j a  v a2  s .  c  o m
     * Saves passed string to file
     *
     * @param filename      path to file
     * @param stringToWrite string to save
     */
    public static void stringToFile(String filename, String stringToWrite) {
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(
                    filename));
            writer.write(stringToWrite);
            writer.flush();
            writer.close();
        } catch (Exception ignored) {
        }
    }
}

Related

  1. writeContatctInfo(String accountId, Vector contactInfo, File contactInfoFile)
  2. writeFile(File file, String data)
  3. writeFile(File file, byte[] data)
  4. writeInstallationFile(File installation)
  5. writeOneLine(String filename, String value)