Earl,

Below is a Java program I've used to find EDI files.  I changed the
checkFile method, my method uses a call to my OBOE package,  this
method simply checks the first 3 bytes for "ISA".  To enhance it you
could add a state table to search for the other primary segments GS,
ST, SE, etc. to verify that the file is X12.

The code is so simple it could easily be converted from Java to C,
C++, VB, ...


Merry Christmas,

Joe McVerry





import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


/**
 * @author joseph mcverry; american coders, ltd.;
[EMAIL PROTECTED]
 * program to search for all files starting with ISA 
 */
public class EDIFileSearch implements Runnable {

        static int hitCount = 0;

        public static void main(String args[]) {
                if (args.length == 0)
                        new EDIFileSearch("./.").run();
                else if (args.length == 1)
                        new EDIFileSearch(args[0]).run();
                else {
                        System.err.println("accepts only one optional argument, 
the
starting directory name");
                }
                System.out.println("found "+ hitCount + " files starting with 
ISA");
        }

        String currentDirName;
        public EDIFileSearch(String inDirectory) {
                // System.out.println("Will search in "+ inDirectory);
                currentDirName = inDirectory;
        }

        public void run() {
                File fdir = new File(currentDirName);
                if (fdir.exists() == false) // huh?
                        return;
                if (fdir.isFile())
                        checkFile(fdir);
                else {
                        File files[] = fdir.listFiles();

                        if (files == null)
                                return;

                        for (int i = 0; i < files.length; i++) {
                                if (files[i].isFile())
                                        checkFile(files[i]);
                                else
                                        try {
                                                new 
EDIFileSearch(files[i].getCanonicalPath()).run();
                                        } catch (IOException e) {
                                                // TODO Auto-generated catch 
block
                                                e.printStackTrace();
                                        }
                        }
                }

        }

        /**
         * @param fdir
         *            a File that is not a directory
         */
        private void checkFile(File fl) {
                if (fl.length() < 200) // let's use a reasonable 
ISA/GS/ST/SE/GE/ISE
 minimal length
                        return;
                if (fl.isHidden())
                        return;
                if (fl.canRead() == false)
                        return;
        
                try {
                        FileReader fr = new FileReader(fl);
                        char cbuf[] = new char[3];
                        fr.read(cbuf);
                        fr.close();
                        if (cbuf[0] == 'I' && cbuf[1] == 'S' && cbuf[2] == 'A') 
{
                                System.out.println("ISA string found in file 
named "
                                                + fl.getCanonicalPath());
                                hitCount++;
                        }
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                }

        }

}



--- In [email protected], Earl Wertheimer <[EMAIL PROTECTED]> wrote:
>
> Happy Holidays  & Great New Year...
> 
> Has anyone encountered a search tool that is EDI aware?
> It could build a database of all EDI documents in certain folders
(or the 
> entire Drive or server)




...
Please use the following Message Identifiers as your subject prefix: <SALES>, 
<JOBS>, <LIST>, <TECH>, <MISC>, <EVENT>, <OFF-TOPIC>

Job postings are welcome, but for job postings or requests for work: <JOBS> IS 
REQUIRED in the subject line as a prefix. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/EDI-L/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/EDI-L/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to