package de.ivu.elect.jee.servlet;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 *  on 28.07.2015.
 */
public class FileStaticResource implements StaticResource {

  private final File file;

  public FileStaticResource(File file) {
    this.file = file;
  }

  @Override
  public long getLastModified() {
    return file.lastModified();
  }

  @Override
  public InputStream getInputStream() throws IOException {
    return new FileInputStream(file);
  }

  @Override
  public String getFileName() {
    return file.getName();
  }

  @Override
  public long getContentLength() {
    return file.length();
  }
}
