Code example for FileWriter

Methods: close, write

0
    } 
 
    public static boolean writeOneLine(String filename, String value) {
        FileWriter fileWriter = null;
        try { 
            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;