SyntaxFix
Write A Post
Hire A Developer
Questions
Simple and Best option retrieve the content mime type from the file location.
Use this imports
import java.nio.file.Files; import java.nio.file.Path;
Code
String type = Files.probeContentType(Path.of(imagePath));