le-annen.javaserver.0.1.source-code.ConfigFileDownloads Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaserver Show documentation
Show all versions of javaserver Show documentation
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;
}
}