Code example for File

Methods: createNewFile, exists

0
                            // if core is off applying cpu freqs fails 
                            || mStderr.contains(": can't create /sys/devices/system/cpu/cpu");
            String lineEnding = System.getProperty("line.separator");
            FileWriter errorWriter = null;
            try { 
                File errorLogFile = new File(
                        Environment.getExternalStorageDirectory()
                                + "/aokp/error.txt"); 
                if (!errorLogFile.exists()) {
                    errorLogFile.createNewFile();
                } 
                errorWriter = new FileWriter(errorLogFile, true);
                // only log the cpu state as offline while writing 
                if (skipOfflineCpu) {
                    errorWriter.write(lineEnding);
                    errorWriter.write("Attempted to write to an offline cpu core (ignore me).");
                } else { 
                    errorWriter.write(TAG + " shell error detected!");
                    errorWriter.write(lineEnding);
                    errorWriter.write("CommandResult {" + this.toString() + '}');
                    errorWriter.write(lineEnding);