Code example for FileWriter

1
        Log.d(TAG, "Test output file: " + outputFile);
        try { 
            if (outputFile != null){
                File extStorage = Environment.getExternalStorageDirectory();
                File outFile = new File(extStorage, outputFile);
                FileWriter writer = new FileWriter(outFile, true);
                BufferedWriter out = new BufferedWriter(writer);
                if (result) {
                    out.append(tag + ":fail\n");
                } else { 
                    out.append(tag + ":pass\n");
                } 
                out.close();
            } 
            if (result) {
                Log.e(TAG, tag + " FAILURE ====================");
                Log.e(TAG, tag + " FAILURE was able to use data");
                Log.e(TAG, tag + " FAILURE ====================");
            } else { 
                Log.d(TAG, tag + " success; unable to use data");
            }