Code example for File

Methods: createNewFile, deleteOnExit

0
     * @throws IOException 
     */ 
    protected abstract void writeValueToDisk(File file, ValT value) throws IOException;
 
    private void cacheToDisk(KeyT key, ValT value) {
        File file = new File(diskCacheDirectory + "/" + getFileNameForKey(key));
        try { 
            file.createNewFile();
            file.deleteOnExit();
 
            writeValueToDisk(file, value);
 
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } 
    } 
 
    private File getFileForKey(KeyT key) {
        return new File(diskCacheDirectory + "/" + getFileNameForKey(key));