Forums Register Login

Get File Type

+Pie Number of slices to send: Send
Hi,

Anyone know how to do the following:

- when i right click on a file whether in windows or linux the properties of the file comes up, i.e. name: x.jpg, Type: JPEG image, size: 30kb

- if i change the file extension of the file to x.png, the type: JPEG image remains the same i.e. Type: JPEG image

i have tried using javax.activation to get the mime type but this seems to work off the extension of the file

anyone know any library or example code?

Cheers,

Niall
+Pie Number of slices to send: Send
I'm not sure what you are trying to do: convert an image from one type to another, or just find out which type an image is? If the latter, then that's what the ImageInfo class does.
+Pie Number of slices to send: Send
i was thinking about ImageInfo but sometimes the file that we are trying to check for the file format (i.e. image/jpeg, image/tiff) is not an image but a video file (video/mpeg, video/x-msvideo) or some other type of file, so i cant use ImageInfo :-(
+Pie Number of slices to send: Send
perhaps, you can use jmimemagic
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1165 times.
Similar Threads
How to get file extension?
Java to Display Data from Database
Problem with error page example
Document Retrival from database.
Determine file (image) type from an InputStream
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:30:36.