Android Text File Write writeTextFile(File file, String[] strArray)

Here you can find the source of writeTextFile(File file, String[] strArray)

Description

write Text File

Declaration

public static void writeTextFile(File file, String[] strArray)
            throws IOException 

Method Source Code

//package com.java2s;

import java.io.*;

public class Main {
    public static void writeTextFile(File file, String str)
            throws IOException {
        DataOutputStream out = null;
        if (null != file) {
            try {
                out = new DataOutputStream(new FileOutputStream(file));
                out.write(str.getBytes());
            } finally {
                if (out != null) {
                    out.close();/*from w ww.  ja v a2s.c o m*/
                }
            }
        }
    }

    public static void writeTextFile(File file, String[] strArray)
            throws IOException {
        String str = "";
        if (null != file && null != strArray) {
            for (int i = 0; i < strArray.length; i++) {
                str += strArray[i];
                if (i != strArray.length - 1)
                    str += "\r\n";
            }

            DataOutputStream out = null;
            try {
                out = new DataOutputStream(new FileOutputStream(file));
                out.write(str.getBytes());
            } finally {
                if (out != null) {
                    out.close();
                }
            }
        }
    }
}

Related

  1. writeFileEnd(String filepath, String text)
  2. WriteFile(String file, String message)
  3. writeNewFile(String filePath, String fileContents)
  4. writeStringToFile(File file, String data)
  5. writeTextFile(File file, String str)