Android FileOutputStream Write saveFileContent(String file, String content, String encode)

Here you can find the source of saveFileContent(String file, String content, String encode)

Description

save File Content

Parameter

Parameter Description
file a parameter
content a parameter
encode a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static void saveFileContent(String file, String content,
        String encode) throws Exception 

Method Source Code

//package com.java2s;

import java.io.FileOutputStream;

import java.io.OutputStream;

public class Main {
    /**//from   www. j a v a2 s  .co m
     * 
     * @param file
     * @param content
     * @param encode
     * @throws Exception
     */
    public static void saveFileContent(String file, String content,
            String encode) throws Exception {
        OutputStream os = null;
        try {
            os = new FileOutputStream(file);

            if (encode != null) {
                os.write(content.getBytes(encode));
            } else {
                os.write(content.getBytes());
            }
            os.flush();
        } catch (Exception e) {
            throw e;
        } finally {
            if (os != null) {
                os.close();
                os = null;
            }
        }

    }
}

Related

  1. WriteArrayOfStringPairs(FileOutputStream stream, ArrayList> pairs)
  2. WriteInt(FileOutputStream stream, int value)
  3. WriteString(FileOutputStream stream, String text)
  4. getXMLAsString(File xmlFile, String fileName)
  5. Write(String fileName, String message)