Java tutorial
/* * @user https://github.com/Egatuts * @repo https://github.com/Egatuts/Exif-Editor.git * @file https://github.com/Egatuts/Exif-Editor/blob/master/src/git/egatuts/android/FileUtils/EgaFileSystem.java * @package git.egatuts.android.FileUtils * @license MIT (http://www.opensource.org/licenses/MIT) */ package git.egatuts.android.FileUtils; import java.io.File; import java.io.IOException; import android.app.Activity; import org.apache.commons.io.FileUtils; import git.egatuts.android.utils.EgaActivityManager; /** * File system management class. * @author Esa Garca * @author EgaTuts * @version 1.0.0 * @created 25/8/2014 at 16:12:33. */ public class EgaFileSystem extends EgaFileSystemBase { /** * The instance reference. */ private static volatile EgaFileSystem instance = null; /** * Protected constructor. */ protected EgaFileSystem() { } /** * Gets the EgaFileSystem instance using lazy initialization. * @return One-time initialization EgaFileSystem instance. */ public static EgaFileSystem getSingleton() { if (instance == null) instance = new EgaFileSystem(); return instance; } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#getActivity() */ @Override public Activity getActivity() { return EgaActivityManager.getActivity(); } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#copyFile(java.io.File, java.io.File) */ @Override public void copyFile(File from, File to) throws IOException { FileUtils.copyFile(from, to); } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#copyFile(java.lang.String, java.lang.String) */ @Override public void copyFile(String from, String to) throws IOException { copyFile(new File(from), new File(to)); } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#deleteFile(java.io.File) */ @Override public void deleteFile(File file) throws IOException { File deletedName = new File(file.getAbsolutePath() + System.currentTimeMillis()); file.renameTo(deletedName); if (!file.isFile()) { file.delete(); return; } FileUtils.deleteDirectory(file); } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#deleteFile(java.lang.String) */ @Override public void deleteFile(String filepath) throws IOException { deleteFile(new File(filepath)); } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#moveFile(java.io.File, java.io.File) */ @Override public void moveFile(File from, File to) throws IOException { copyFile(from, to); deleteFile(from); } /** * (non-Javadoc) * @see git.egatuts.android.FileUtils.EgaFileSystemBase#moveFile(java.lang.String, java.lang.String) */ @Override public void moveFile(String from, String to) throws IOException { moveFile(new File(from), new File(to)); } }