• Post Reply Bookmark Topic Watch Topic
  • New Topic

determining the file type in java  RSS feed

 
bharadwaja kambhammettu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

Without considering the file extension, i am trying to determine the file type by reading the file contents. Is that possible ?

I`ve observed that every .pdf file has "%PDF-1.3" or "%PDF-1.4" etc as the very first chars. If i try removing them, the file `ll still be a .pdf but can not be opened by the Acrobat Reader. I think that `ll help me determine whether a file is a .pdf.

My actual trouble is in reading a ".doc" file. Is there any way, i can read the bytes from a .doc file and determine whether it is actually a .doc file ? Can we identify other MS - Office files also in this manner ?

thanks in advance.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to search on MSDN.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!