Android Utililty Methods FileOutputStream Write

List of utility methods to do FileOutputStream Write

Description

The list of methods to do FileOutputStream Write are organized into topic(s).

Method

voidWriteArrayOfStringPairs(FileOutputStream stream, ArrayList> pairs)
Write Array Of String Pairs
WriteInt(stream, pairs.size());
for (Pair<String, String> pair : pairs) {
    WriteString(stream, pair.getFirst());
    WriteString(stream, pair.getSecond());
voidWriteInt(FileOutputStream stream, int value)
Write Int
stream.write(IntToBytes(value));
voidWriteString(FileOutputStream stream, String text)
Write String
byte[] bytes = text.getBytes();
WriteInt(stream, bytes.length);
stream.write(bytes);
voidsaveFileContent(String file, String content, String encode)
save File Content
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;
StringgetXMLAsString(File xmlFile, String fileName)
get XML As String
try {
    File file = new File(xmlFile, fileName);
    InputStream inputStream = new FileInputStream(file.getPath());
    StringBuffer outXml = new StringBuffer();
    byte[] b = new byte[4096];
    try {
        for (int n; (n = inputStream.read(b)) != -1;) {
            outXml.append(new String(b, 0, n));
...
voidWrite(String fileName, String message)
Write
try {
    FileOutputStream outSTr = null;
    try {
        outSTr = new FileOutputStream(new File(fileName));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    BufferedOutputStream Buff = new BufferedOutputStream(outSTr);
...