Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the Content-Type of a File

807603Nov 21 2007 — edited Dec 14 2007
Hi..,

There is a PDF file which i want to upload on my server.
Before upload,I want to set the Content-type of this file.
So i have code the following lines to get the Content Type of file.
File FileName=new File("c:\\abc.pdf");
FileTypeMap fMap=FileTypeMap.getDefaultFileTypeMap();
String sContentType="";
sContentType= fMap.getContentType(FileName);
After execution of this code it is returning the content-type
"application/octet-stream"

So how can i get the Content-Type of this file?

Can anybody help me to solve this problem
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2008
Added on Nov 21 2007
15 comments
1,201 views