FileDocCategorySizeDatePackage
TestAudioTagger.javaAPI DocJaudiotagger 2.0.44755Thu Apr 28 14:55:18 BST 2011org.jaudiotagger.test

TestAudioTagger

public class TestAudioTagger extends Object
Simple class that will attempt to recusively read all files within a directory, flags errors that occur.

Fields Summary
private static int
count
private static int
failed
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        TestAudioTagger test = new TestAudioTagger();

        if (args.length == 0)
        {
            System.err.println("usage TestAudioTagger Dirname");
            System.err.println("      You must enter the root directory");
            System.exit(1);
        }
        else if (args.length > 1)
        {
            System.err.println("usage TestAudioTagger Dirname");
            System.err.println("      Only one parameter accepted");
            System.exit(1);
        }
        File rootDir = new File(args[0]);
        if (!rootDir.isDirectory())
        {
            System.err.println("usage TestAudioTagger Dirname");
            System.err.println("      Directory " + args[0] + " could not be found");
            System.exit(1);
        }
        Date start = new Date();
        System.out.println("Started to read from:" + rootDir.getPath() + " at " + DateFormat.getTimeInstance().format(start));
        test.scanSingleDir(rootDir);
        Date finish = new Date();
        System.out.println("Started to read from:" + rootDir.getPath() + " at " + DateFormat.getTimeInstance().format(start));
        System.out.println("Finished to read from:" + rootDir.getPath() + DateFormat.getTimeInstance().format(finish));
        System.out.println("Attempted  to read:" + count);
        System.out.println("Successful to read:" + (count - failed));
        System.out.println("Failed     to read:" + failed);

    
private voidscanSingleDir(java.io.File dir)
Recursive function to scan directory

param
dir


                
        
    

        final File[] audioFiles = dir.listFiles(new AudioFileFilter(false));
        if (audioFiles.length > 0)
        {
            for (File audioFile : audioFiles)
            {
                count++;
                try
                {
                    AudioFileIO.read(audioFile);
                }
                catch (Throwable t)
                {
                    System.err.println("Unable to read record:" + count + ":" + audioFile.getPath());
                    failed++;
                    t.printStackTrace();
                }
            }
        }

        final File[] audioFileDirs = dir.listFiles(new DirFilter());
        if (audioFileDirs.length > 0)
        {
            for (File audioFileDir : audioFileDirs)
            {
                scanSingleDir(audioFileDir);
            }
        }