All Downloads are FREE. Search and download functionalities are using the official Maven repository.

le-annen.javaserver.0.1.source-code.ConfigFileDownloads Maven / Gradle / Ivy

Go to download

A minimal java http server which fulfills small portions of the http specifications. This is not a full fledged or secure server. It should only be used for learning purposes and contains no guarantees of any king.

The newest version!
import java.io.File;
import java.util.ArrayList;

class ConfigFileDownloads {
  private ArrayList filesToNotAddDownloadParameter;

  ConfigFileDownloads() {
    filesToNotAddDownloadParameter = new ArrayList<>();
    this.initialize(this.filesToNotAddDownloadParameter);
  }

  private void initialize(ArrayList fileList) {
    fileList.add("jpg");
    fileList.add("jpeg");
    fileList.add("html");
    fileList.add("png");
    fileList.add("pdf");
  }

  public Boolean isDownloadable(String filePath) {
    String[] fileArray = filePath.split("\\.");
    String fileExtension = fileArray[fileArray.length - 1];
    Boolean isDownloadable = !this.filesToNotAddDownloadParameter.contains(fileExtension);
    File file = new File(filePath);
    Boolean isDirectory =  file.isDirectory();
    return isDownloadable && !isDirectory;

  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy