How do I know that a particular file is in binary or text format without relying on the extention of a file?
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.