Android FileOutputStream Write Write(String fileName, String message)

Here you can find the source of Write(String fileName, String message)

Description

Write

Declaration

public static void Write(String fileName, String message) 

Method Source Code

//package com.java2s;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import java.net.MalformedURLException;

public class Main {
    public static void Write(String fileName, String message) {

        try {//  w w w . j  a v a2  s . c o  m
            FileOutputStream outSTr = null;
            try {
                outSTr = new FileOutputStream(new File(fileName));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            BufferedOutputStream Buff = new BufferedOutputStream(outSTr);
            byte[] bs = message.getBytes();
            Buff.write(bs);
            Buff.flush();
            Buff.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

Related

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