Android Open Source - FileShare Temp File Factory






From Project

Back to project page FileShare.

License

The source code is released under:

MIT License

If you think the Android project FileShare listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.csyangchsh.fileshare.util;
/*from  w w w.j  a v a2  s. c  o m*/
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author csyangchsh
 * 2014-08-28
 */
public class TempFileFactory {

    private final String tmpDir;
    private final List<File> tempFiles;

    public TempFileFactory() {
        //FIXME use android temp dir?
        tmpDir = System.getProperty("java.io.tmpdir");
        tempFiles = new ArrayList<File>();
    }

    public File createTempFile() throws IOException {
        File tempFile = File.createTempFile("FileShare-", "", new File(tmpDir));
        tempFiles.add(tempFile);
        return tempFile;
    }

    public void destroy() {
        for (File file : tempFiles) {
            try {
                file.delete();
            } catch (Exception ignored) {
            }
        }
        tempFiles.clear();
    }
}




Java Source Code List

com.csyangchsh.fileshare.ApplicationTest.java
com.csyangchsh.fileshare.FSApplication.java
com.csyangchsh.fileshare.FileActivity.java
com.csyangchsh.fileshare.FileListAdapter.java
com.csyangchsh.fileshare.FileService.java
com.csyangchsh.fileshare.SplashActivity.java
com.csyangchsh.fileshare.util.DefaultFileFilter.java
com.csyangchsh.fileshare.util.FileHandler.java
com.csyangchsh.fileshare.util.MiniFileServer.java
com.csyangchsh.fileshare.util.TempFileFactory.java
com.csyangchsh.fileshare.util.Util.java