Code example for File

Methods: exists, length, renameTo

0
	 * Clear the error log each time the app is started; preserve previous if non-empty 
	 */ 
	public static void clearLog() { 
		try { 
			try {  
				File orig = new File(StorageUtils.getErrorLog());
				if (orig.exists() && orig.length() > 0) {
					File backup = new File(StorageUtils.getErrorLog() + ".bak");
					orig.renameTo(backup);					
				} 
			} catch (Exception e) {
				// Ignore backup failure... 
			} 
			BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(StorageUtils.getErrorLog()), "utf8"), 8192);
			out.write("");
			out.close();
		} catch (Exception e1) {
			// do nothing - we can't log an error in the error logger. (and we don't want to FC the app) 
		} 
	}