Code example for FileWriter

Methods: close, write

0
        FileWriter writer = null;
        float avgFrameRate;
        int totalNumberOfFrame = 0;
        try { 
            Log.w(TAG, "file: " +LOG_FILE);
            writer = new FileWriter(LOG_FILE, true); // true = append
            totalNumberOfFrame = sEndFrameNo - sStartFrameNo;
            avgFrameRate = getAverageFrameRate(totalNumberOfFrame, sDuration);
            writer.write(String.format("%s:%.2f\n", sTestCaseName, avgFrameRate));
        } catch (IOException e) {
            Log.w(TAG, "Can't write sdcard log file", e);
        } finally { 
            try { 
                if (writer != null)
                    writer.close();
            } catch (IOException e) {
                Log.e(TAG, "IOException " + e.toString());
            } 
        } 
    }