Joe Sam Shirah wrote:
>         As you might expect from the response so far, it is nearly
> impossible, in the general case, to determine text/binary format with 100%
> reliability.  Most attempts check for magic numbers ( like 0xCAFEBABE for
> Java classes ) and values greater than 127 to detect non-ASCII values.

Actually, I found an open source solution that I can hand a byte array
and it will tell me what kind of file it is.

It's jMimeMagic on sourceforge (don't have the url hand right now).

I just read the first two K of the file into a byte array, use
jMimeMagic to check the file ... if it can figure out the file, I try
again after using CharConvert to change the CCSID on the byte array.

Seems to work ok so far.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.