Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

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

0
Posted

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

0

Location: http://www.jguru.com/faq/view.jsp?EID=135905 Created: Aug 27, 2000 Modified: 2001-08-18 18:00:46.152 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Jigar Shah (http://www.jguru.com/guru/viewbio.jsp?EID=119342 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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.