How do I know that a particular file is in binary or text format without relying on the extention of a file?

John Zukowski

Basically, you guess by reading the first few bytes of the file. Most binary file formats have a hardcoded constant there, called a magic number. As long as you have a complete list of magic numbers for the possible binary file formats you might come across, you can try your best to determine if something is binary / text. For instance, all Java class files start with 0xCAFEBABE.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact