Code example for File

Methods: exists, getAbsolutePath, getParentFile, mkdirs

0
 
	public static void createParentDirectory(File dest) throws TodoException {
		if (dest == null) {
			throw new TodoException("createParentDirectory: dest is null"); 
		} 
		File dir = dest.getParentFile();
		if (dir != null && !dir.exists()) {
			createParentDirectory(dir);
		} 
		if (!dir.exists()) {
			if (!dir.mkdirs()) {
				Log.e(TAG, "Could not create dirs: " + dir.getAbsolutePath());
				throw new TodoException("Could not create dirs: " 
						+ dir.getAbsolutePath());
			} 
		} 
	} 
 
	public static void renameFile(File origFile, File newFile, boolean overwrite) {
		if (!origFile.exists()) {
			Log.e(TAG, "Error renaming file: " + origFile + " does not exist");