• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

determining the file type in java

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to search on MSDN.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic