Code example for FileOutputStream

Methods: close, flush, write

0
 
	public boolean writeLinesToFile(String filename, String lines) {
		OutputStream out = null;
		boolean returnStatus = false;
		try { 
			out = new FileOutputStream(filename);
			out.write(lines.getBytes());
			out.flush();
		} catch (Exception e) {
			Log.d(MSG_TAG, "Unexpected error - Here is what I know: "
					+ e.getMessage());
		} finally { 
			try { 
				if (out != null)
					out.close();
				returnStatus = true;
			} catch (IOException e) {
				returnStatus = false;
			} 
		} 
		return returnStatus;