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

com.softicar.platform.common.io.mime.MimeTypeDeterminer Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
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 "";
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy