Namely, how would you tell an archive (jar/rar/etc.) file from a textual (xml/txt, encoding-independent) one?
Namely, how would you tell an archive (jar/rar/etc.) file from a textual (xml/txt, encoding-independent)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no guaranteed way, but here are a couple of possibilities:
Look for a header on the file. Unfortunately, headers are file-specific, so while you might be able to find out that it’s a RAR file, you won’t get the more generic answer of whether it’s text or binary.
Count the number of character vs. non-character types. Text files will be mostly alphabetical characters while binary files – especially compressed ones like rar, zip, and such – will tend to have bytes more evenly represented.
Look for a regularly repeating pattern of newlines.