Android Utililty Methods File Write

List of utility methods to do File Write

Description

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

Method

voidwriteContatctInfo(String accountId, Vector contactInfo, File contactInfoFile)
write Contatct Info
contactInfoFile.getParentFile().mkdirs();
FileOutputStream contactFileOutputStream = new FileOutputStream(
        contactInfoFile);
DataOutputStream out = new DataOutputStream(contactFileOutputStream);
out.writeUTF((String) contactInfo.get(0));
out.writeInt(((Integer) (contactInfo.get(1))).intValue());
for (int i = 2; i < contactInfo.size(); ++i) {
    out.writeUTF((String) contactInfo.get(i));
...
voidwriteFile(File file, String data)
write File
FileWriter fstream = new FileWriter(file);
BufferedWriter out = new BufferedWriter(fstream);
out.write(data);
out.close();
voidwriteFile(File file, byte[] data)
write File
DataOutputStream out = null;
if (null != file && null != data) {
    try {
        out = new DataOutputStream(new FileOutputStream(file));
        out.write(data);
    } finally {
        if (out != null) {
            out.close();
...
voidwriteInstallationFile(File installation)
write Installation File
FileOutputStream out = new FileOutputStream(installation);
String id = UUID.randomUUID().toString();
out.write(id.getBytes());
out.close();
booleanwriteOneLine(String filename, String value)
write One Line
FileWriter fileWriter = null;
try {
    fileWriter = new FileWriter(filename);
    fileWriter.write(value);
} catch (IOException e) {
    String Error = "Error writing { " + value + " } to file: "
            + filename;
    Log.e(TAG, Error, e);
...
voidstringToFile(String filename, String stringToWrite)
Saves passed string to file
try {
    BufferedWriter writer = new BufferedWriter(new FileWriter(
            filename));
    writer.write(stringToWrite);
    writer.flush();
    writer.close();
} catch (Exception ignored) {