string To Output Stream - Android File Input Output

Android examples for File Input Output:OutputStream

Description

string To Output Stream

Demo Code


//package com.java2s;

import java.io.IOException;

import java.io.OutputStream;

public class Main {

    public static void stringToOutputStream(String str, OutputStream output) {
        if (str != null && output != null) {
            try {
                output.write(str.getBytes());
            } catch (Exception e) {
                e.printStackTrace();/*from   w  w w .j a  v  a  2s  .co  m*/
            } finally {
                closeOutputStream(output);
            }
        }
    }

    public static void closeOutputStream(OutputStream output) {
        if (output != null) {
            try {
                output.close();
            } catch (IOException e) {
            }
        }
    }
}

Related Tutorials