com.softicar.platform.common.io.mime.MimeTypeDeterminer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.io.mime;
import java.util.Optional;
class MimeTypeDeterminer {
private final String filename;
public MimeTypeDeterminer(String filename) {
this.filename = filename;
}
public Optional getMimeType() {
return MimeType.getByFilenameSuffix(getFilenameSuffix());
}
private String getFilenameSuffix() {
int pointIndex = filename.lastIndexOf('.');
if (pointIndex >= 0 && pointIndex + 1 < filename.length()) {
return filename.substring(pointIndex + 1);
} else {
return "";
}
}
}