Java tutorial
//package com.java2s; import android.text.TextUtils; import java.io.BufferedOutputStream; import java.io.OutputStream; public class Main { public static void writeData(OutputStream stream, String str) { if (null == stream || TextUtils.isEmpty(str)) { return; } str = str + "\r\n"; try { BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(stream); bufferedOutputStream.write(str.getBytes()); bufferedOutputStream.flush(); } catch (Exception ex) { ex.printStackTrace(); } finally { } } }