Android File Write writeOneLine(String filename, String value)

Here you can find the source of writeOneLine(String filename, String value)

Description

write One Line

Declaration

public static boolean writeOneLine(String filename, String value) 

Method Source Code

//package com.java2s;

import android.util.Log;

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

public class Main {
    private static final String TAG = Thread.currentThread()
            .getStackTrace()[1].getClassName();

    public static boolean writeOneLine(String filename, String value) {
        FileWriter fileWriter = null;
        try {/*from  w  ww.  ja v  a2  s  . c om*/
            fileWriter = new FileWriter(filename);
            fileWriter.write(value);
        } catch (IOException e) {
            String Error = "Error writing { " + value + " } to file: "
                    + filename;
            Log.e(TAG, Error, e);
            return false;
        } finally {
            if (fileWriter != null) {
                try {
                    fileWriter.close();
                } catch (IOException ignored) {
                    // failed to close writer
                }
            }
        }
        return true;
    }
}

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. stringToFile(String filename, String stringToWrite)