view src/cachingfilter/CachedFile.java @ 58:41d76bd6268a

add doc for ssl
author Vadim Filimonov <fffilimonov@yandex.ru>
date Tue, 30 Nov 2021 09:32:14 +0200
parents 7ecd1a4ef557
children
line wrap: on
line source

package cachingfilter;

import java.io.File;
import java.io.IOException;

import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


final class CachedFile implements CachedPage {
	private static final Logger logger = LoggerFactory.getLogger(CachedFile.class);
	private final File file;

	CachedFile( File parent, String child ) {
		this.file = new File(parent,child);
	}

	public String name() {
		return file.getName();
	}

	public boolean exists() {
		return file.exists();
	}

	public File lastFile() {
		return file;
	}

	public File newFile() throws IOException {
		delete();
		if( !file.createNewFile() )
			throw new RuntimeException("couldn't create "+file);
		return file;
	}

	public void deleteNewFile() {
		if( !delete() )
			throw new RuntimeException("couldn't delete "+file);
	}

	public boolean delete() {
		return file.delete();
	}

	public String toString() {
		return file.toString();
	}

}