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. david
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.