Example usage for java.io File isHidden

List of usage examples for java.io File isHidden

Introduction

In this page you can find the example usage for java.io File isHidden.

Prototype

public boolean isHidden() 

Source Link

Document

Tests whether the file named by this abstract pathname is a hidden file.

Usage

From source file:Main.java

public static void main(String[] args) {
    File file = new File("C:/Demo.txt");
    System.out.println(file.isHidden());
}

From source file:MainClass.java

public static void main(String[] args) {

    // Create an object that is a directory
    File myFile = new File("test.txt");
    System.out.println(myFile + (myFile.isHidden() ? " is" : " is not") + " hidden");
}

From source file:Main.java

public static void main(String[] args) {

    // create new file
    File f = new File("c:/test.txt");

    // true if the file path is a hidden file
    boolean bool = f.isHidden();

    // get the path
    String path = f.getPath();/*from w  ww  .java  2s.  c o m*/

    System.out.print(path + " is file hidden? " + bool);

}

From source file:com.blogspot.devsk.l2j.geoconv.GeoGonv.java

public static void main(String[] args) {

    if (args == null || args.length == 0) {
        System.out.println("File name was not specified, [\\d]{1,2}_[\\d]{1,2}.txt will be used");
        args = new String[] { "[\\d]{1,2}_[\\d]{1,2}.txt" };
    }/*from ww w  . j a v a2  s.com*/

    File dir = new File(".");
    File[] files = dir.listFiles((FileFilter) new RegexFileFilter(args[0]));

    ArrayList<File> checked = new ArrayList<File>();
    for (File file : files) {
        if (file.isDirectory() || file.isHidden() || !file.exists()) {
            System.out.println(file.getAbsoluteFile() + " was ignored.");
        } else {
            checked.add(file);
        }
    }

    if (OUT_DIR.exists() && OUT_DIR.isDirectory() && OUT_DIR.listFiles().length > 0) {
        try {
            System.out.println("Directory with generated files allready exists, making backup...");
            FileUtils.moveDirectory(OUT_DIR, new File("generated-backup-" + System.currentTimeMillis()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    if (!OUT_DIR.exists()) {
        OUT_DIR.mkdir();
    }

    for (File file : checked) {
        GeoConvThreadFactory.startThread(new ParseTask(file));
    }
}

From source file:edu.cuhk.hccl.IDConverter.java

public static void main(String[] args) {
    if (args.length < 2) {
        printUsage();/*from   w  w  w. j  av  a2s.c o  m*/
    }

    try {
        File inFile = new File(args[0]);
        File outFile = new File(args[1]);

        if (inFile.isDirectory()) {
            System.out.println("ID Converting begins...");
            FileUtils.forceMkdir(outFile);
            for (File file : inFile.listFiles()) {
                if (!file.isHidden())
                    processFile(file, new File(outFile.getAbsolutePath() + "/"
                            + FilenameUtils.removeExtension(file.getName()) + "-long.txt"));
            }
        } else if (inFile.isFile()) {
            System.out.println("ID Converting begins...");
            processFile(inFile, outFile);
        } else {
            printUsage();
        }

        System.out.println("ID Converting finished.");

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.l2jfree.tools.ProjectSettingsSynchronizer.java

public static void main(String[] args) throws IOException {
    final File src = new File(".").getCanonicalFile();
    System.out.println("Copying from: " + src);
    System.out.println();// w w w . j a va 2  s  .  c  om

    final List<File> destinations = new ArrayList<File>();
    for (File dest : src.getParentFile().listFiles()) {
        if (dest.isHidden() || !dest.isDirectory())
            continue;

        destinations.add(dest);
        System.out.println("Copying to: " + dest);
    }
    System.out.println();

    // .project
    System.out.println(".project");
    System.out.println("================================================================================");
    {
        final List<String> lines = FileUtils.readLines(new File(src, ".project"));

        for (File dest : destinations) {
            lines.set(2, lines.get(2).replaceAll(src.getName(), dest.getName()));
            writeLines(dest, ".project", lines);
            lines.set(2, lines.get(2).replaceAll(dest.getName(), src.getName()));
        }
    }
    System.out.println();

    // .classpath
    System.out.println(".classpath");
    System.out.println("================================================================================");
    {
        final List<String> lines = FileUtils.readLines(new File(src, ".classpath"));

        for (File dest : destinations) {
            if (dest.getName().endsWith("-main") || dest.getName().endsWith("-datapack")) {
                final ArrayList<String> tmp = new ArrayList<String>();

                for (String line : lines)
                    if (!line.contains("classpathentry"))
                        tmp.add(line);

                writeLines(dest, ".classpath", tmp);
                continue;
            }

            writeLines(dest, ".classpath", lines);
        }
    }
    System.out.println();

    // .settings
    System.out.println(".settings");
    System.out.println("================================================================================");
    for (File settingsFile : new File(src, ".settings").listFiles()) {
        if (settingsFile.getName().endsWith(".prefs")) {
            System.out.println(".settings/" + settingsFile.getName());
            System.out.println(
                    "--------------------------------------------------------------------------------");

            final List<String> lines = FileUtils.readLines(settingsFile);

            if (lines.get(0).startsWith("#"))
                lines.remove(0);

            for (File dest : destinations) {
                writeLines(new File(dest, ".settings"), settingsFile.getName(), lines);
            }
            System.out.println();
        }
    }
    System.out.println();
}

From source file:Attr.java

public static void main(String args[]) {
    File path = new File(args[0]); // grab command-line argument
    String exists = getYesNo(path.exists());
    String canRead = getYesNo(path.canRead());
    String canWrite = getYesNo(path.canWrite());
    String isFile = getYesNo(path.isFile());
    String isHid = getYesNo(path.isHidden());
    String isDir = getYesNo(path.isDirectory());
    String isAbs = getYesNo(path.isAbsolute());
    System.out.println("File attributes for '" + args[0] + "'");
    System.out.println("Exists    : " + exists);
    if (path.exists()) {
        System.out.println("Readable   : " + canRead);
        System.out.println("Writable   : " + canWrite);
        System.out.println("Is directory : " + isDir);
        System.out.println("Is file    : " + isFile);
        System.out.println("Is hidden   : " + isHid);
        System.out.println("Absolute path : " + isAbs);
    }/*from   w  ww.j av  a  2s .c  o m*/
}

From source file:edu.msu.cme.rdp.seqmatch.cli.SeqMatchMain.java

public static void main(String[] args) throws Exception {

    if (args.length == 0) {
        System.err.println("USAGE: SeqMatchMain [train|seqmatch] <args>");
        return;//from www. j av a 2 s  .  co m
    }

    String cmd = args[0];
    args = Arrays.copyOfRange(args, 1, args.length);

    if (cmd.equals("train")) {
        if (args.length != 2) {
            System.err.println("USAGE: train <reference sequences> <trainee_out_file_prefix>"
                    + "\nMultiple trainee output files might be created, each containing maximum "
                    + Trainee.MAX_NUM_SEQ + " sequences");
            return;
        }

        File refSeqs = new File(args[0]);
        File traineeFileOut = new File(args[1]);

        //maybe more than 1 trainee files need to be created, depending on the number of seqs
        CreateMultiMatchFromFile.getMultiTrainee(refSeqs, traineeFileOut);
    } else if (cmd.equals("seqmatch")) {
        File refFile = null;
        File queryFile = null;
        HashMap<String, String> descMap = new HashMap<String, String>();
        PrintStream out = new PrintStream(System.out);
        int knn = 20;
        float minSab = .5f;

        try {
            CommandLine line = new PosixParser().parse(options, args);

            if (line.hasOption("knn")) {
                knn = Integer.parseInt(line.getOptionValue("knn"));
            }

            if (line.hasOption("sab")) {
                minSab = Float.parseFloat(line.getOptionValue("sab"));
            }
            if (line.hasOption("desc")) {
                descMap = readDesc(new File(line.getOptionValue("desc")));
            }
            if (line.hasOption("outFile")) {
                out = new PrintStream(new File(line.getOptionValue("outFile")));
            }

            args = line.getArgs();

            if (args.length != 2) {
                throw new Exception("Unexpected number of command line arguments");
            }

            refFile = new File(args[0]);
            queryFile = new File(args[1]);

        } catch (Exception e) {
            new HelpFormatter().printHelp("seqmatch <refseqs | trainee_file_or_dir> <query_file>\n"
                    + " trainee_file_or_dir is a single trainee file or a directory containing multiple trainee files",
                    options);
            System.err.println("Error: " + e.getMessage());
            return;
        }

        SeqMatch seqmatch = null;
        if (refFile.isDirectory()) { // a directory of trainee files
            List<SeqMatch> engineList = new ArrayList<SeqMatch>();
            for (File f : refFile.listFiles()) {
                if (!f.isHidden()) {
                    TwowaySeqMatch match = new TwowaySeqMatch(new SeqMatchEngine(new StorageTrainee(f)));
                    engineList.add(match);
                }
            }
            seqmatch = new MultiTraineeSeqMatch(engineList);
        } else { // a single fasta file or trainee file
            if (SeqUtils.guessFileFormat(refFile) == SequenceFormat.UNKNOWN) {
                seqmatch = CLISeqMatchFactory.trainTwowaySeqMatch(new StorageTrainee(refFile));
            } else {
                seqmatch = CreateMultiMatchFromFile.getMultiMatch(refFile);
            }
        }

        out.println("query name\tmatch seq\torientation\tS_ab score\tunique oligomers\tdescription");

        SeqReader reader = new SequenceReader(queryFile);
        Sequence seq;

        while ((seq = reader.readNextSequence()) != null) {
            SeqMatchResultSet resultSet = seqmatch.match(seq, knn);
            for (SeqMatchResult result : resultSet) {
                char r = '+';
                if (result.isReverse()) {
                    r = '-';
                }

                if (result.getScore() > minSab) {
                    out.println(seq.getSeqName() + "\t" + result.getSeqName() + "\t" + r + "\t"
                            + result.getScore() + "\t" + resultSet.getQueryWordCount() + "\t"
                            + descMap.get(result.getSeqName()));
                }
            }
        }

        out.close();
    } else {
        throw new IllegalArgumentException("USAGE: SeqMatchMain [train|seqmatch] <args>");
    }
}

From source file:nl.mpi.tla.isle2clarin.Main.java

public static void main(String[] args) {
    try {/*from   w  w w  .  j a  v  a 2 s.c  om*/
        // initialize CMDI2IMDI
        boolean validateIMDI = false;
        boolean validateCMDI = false;
        TreeSet<String> skip = new TreeSet<>();
        Translator imdi2cmdi = new TranslatorImpl();
        SchemAnon tron = new SchemAnon(Main.class.getResource("/IMDI_3.0.xsd"));
        // check command line
        OptionParser parser = new OptionParser("ics:?*");
        OptionSet options = parser.parse(args);
        if (options.has("i"))
            validateIMDI = true;
        if (options.has("c"))
            validateCMDI = true;
        if (options.has("s"))
            skip = loadSkipList((String) options.valueOf("s"));
        if (options.has("?")) {
            showHelp();
            System.exit(0);
        }
        List arg = options.nonOptionArguments();
        if (arg.size() < 1 && arg.size() > 2) {
            System.err.println("FTL: none or too many non-option arguments!");
            showHelp();
            System.exit(1);
        }
        if (arg.size() > 1) {
            if (options.has("s")) {
                System.err.println("FTL: -s option AND <FILE> argument, use only one!");
                showHelp();
                System.exit(1);
            }
            skip = loadSkipList((String) arg.get(1));
        }
        Collection<File> inputs = null;
        File in = new File((String) arg.get(0));
        if (in.isDirectory()) {
            inputs = FileUtils.listFiles(in, new String[] { "imdi" }, true);
        } else if (in.isFile()) {
            inputs = loadInputList(in);
        } else {
            System.err.println("FTL: unknown type of <INPUT>!");
            showHelp();
            System.exit(1);
        }
        int i = 0;
        int s = inputs.size();
        for (File input : inputs) {
            i++;
            try {
                String path = input.getAbsolutePath();
                //System.err.println("DBG: absolute path["+path+"]");
                //System.err.println("DBG: relative path["+path.replaceAll("^" + in.getAbsolutePath() + "/", "")+"]");
                if (input.isHidden()) {
                    System.err.println("WRN:" + i + "/" + s + ": file[" + path + "] is hidden, skipping it.");
                    continue;
                } else if (path.matches(".*/(corpman|sessions)/.*")) {
                    System.err.println("WRN:" + i + "/" + s + ": file[" + path
                            + "] is in a corpman or sessions dir, skipping it.");
                    continue;
                } else if (skip.contains(path.replaceAll("^" + in.getAbsolutePath() + "/", ""))) {
                    System.err.println(
                            "WRN:" + i + "/" + s + ": file[" + path + "] is in the skip list, skipping it.");
                    continue;
                } else if (skip.contains(path)) {
                    System.err.println(
                            "WRN:" + i + "/" + s + ": file[" + path + "] is in the skip list, skipping it.");
                    continue;
                } else
                    System.err.println("DBG:" + i + "/" + s + ": convert file["
                            + path.replaceAll("^" + (String) arg.get(0) + "/", "") + "]");
                if (validateIMDI) {
                    // validate IMDI
                    if (!tron.validate(input)) {
                        System.err.println(
                                "ERR:" + i + "/" + s + ": invalid file[" + input.getAbsolutePath() + "]");
                        for (Message msg : tron.getMessages()) {
                            System.out.println("" + (msg.isError() ? "ERR: " : "WRN: ") + i + "/" + s + ": "
                                    + (msg.getLocation() != null ? "at " + msg.getLocation() : ""));
                            System.out.println("" + (msg.isError() ? "ERR: " : "WRN: ") + i + "/" + s + ": "
                                    + msg.getText());
                        }
                    } else
                        System.err.println(
                                "DBG:" + i + "/" + s + ": valid file[" + input.getAbsolutePath() + "]");
                }
                // IMDI 2 CMDI
                File output = new File(input.getAbsolutePath().replaceAll("\\.imdi$", ".cmdi"));
                PrintWriter out = new PrintWriter(output.getAbsolutePath());
                Map<String, Object> params = new HashMap<>();
                params.put("formatCMDI", Boolean.FALSE);
                imdi2cmdi.setTransformationParameters(params);
                out.print(imdi2cmdi.getCMDI(input.toURI().toURL(), ""));
                out.close();
                System.err.println("DBG:" + i + "/" + s + ": wrote   file[" + output.getAbsolutePath() + "]");
                if (validateCMDI) {
                    CMDIValidatorConfig.Builder builder = new CMDIValidatorConfig.Builder(output,
                            new Handler());
                    CMDIValidator validator = new CMDIValidator(builder.build());
                    SimpleCMDIValidatorProcessor processor = new SimpleCMDIValidatorProcessor();
                    processor.process(validator);
                }
            } catch (Exception ex) {
                System.err.println("ERR:" + i + "/" + s + ":" + input + ":" + ex);
                ex.printStackTrace(System.err);
            }
        }
    } catch (Exception ex) {
        System.err.println("FTL: " + ex);
        ex.printStackTrace(System.err);
    }
}

From source file:nl.mpi.tla.lat2fox.Main.java

public static void main(String[] args) {
    File rfile = null;/*from  w  w w.j  a  v  a 2  s.co m*/
    String dir = ".";
    String fdir = null;
    String idir = null;
    String bdir = null;
    String xdir = null;
    String pdir = null;
    String mdir = null;
    String cext = "cmdi";
    String cfile = null;
    String dfile = null;
    String mfile = null;
    String oxp = null;
    String axp = null;
    String server = null;
    XdmNode collsDoc = null;
    boolean validateFOX = false;
    boolean laxResourceCheck = false;
    boolean createCMDObject = true;
    boolean relationCheck = true;
    int ndir = 0;
    // check command line
    OptionParser parser = new OptionParser("zhlve:r:f:i:x:p:q:n:c:d:m:o:a:s:b:?*");
    OptionSet options = parser.parse(args);
    if (options.has("l"))
        laxResourceCheck = true;
    if (options.has("v"))
        validateFOX = true;
    if (options.has("h"))
        createCMDObject = false;
    if (options.has("z"))
        relationCheck = false;
    if (options.has("e"))
        cext = (String) options.valueOf("e");
    if (options.has("r"))
        rfile = new File((String) options.valueOf("r"));
    if (options.has("f"))
        fdir = (String) options.valueOf("f");
    if (options.has("i"))
        idir = (String) options.valueOf("i");
    if (options.has("x"))
        xdir = (String) options.valueOf("x");
    if (options.has("p"))
        pdir = (String) options.valueOf("p");
    if (options.has("q"))
        mdir = (String) options.valueOf("q");
    if (options.has("b"))
        bdir = (String) options.valueOf("b");
    if (options.has("c")) {
        cfile = (String) options.valueOf("c");
        File c = new File(cfile);
        if (!c.isFile()) {
            System.err.println("FTL: -c expects a <FILE> argument!");
            showHelp();
            System.exit(1);
        }
        if (!c.canRead()) {
            System.err.println("FTL: -c <FILE> argument isn't readable!");
            showHelp();
            System.exit(1);
        }
        try {
            collsDoc = SaxonUtils.buildDocument(new StreamSource(cfile));
        } catch (Exception ex) {
            System.err.println("FTL: can't read collection <FILE>[" + cfile + "]: " + ex);
            ex.printStackTrace(System.err);
        }
    }
    if (options.has("d")) {
        dfile = (String) options.valueOf("d");
        File d = new File(dfile);
        if (!d.isFile()) {
            System.err.println("FTL: -d expects a <FILE> argument!");
            showHelp();
            System.exit(1);
        }
        if (!d.canRead()) {
            System.err.println("FTL: -d <FILE> argument isn't readable!");
            showHelp();
            System.exit(1);
        }
    }
    if (options.has("m")) {
        mfile = (String) options.valueOf("m");
        File m = new File(mfile);
        if (!m.isFile()) {
            System.err.println("FTL: -m expects a <FILE> argument!");
            showHelp();
            System.exit(1);
        }
        if (!m.canRead()) {
            System.err.println("FTL: -m <FILE> argument isn't readable!");
            showHelp();
            System.exit(1);
        }
    }
    if (options.has("n")) {
        try {
            ndir = Integer.parseInt((String) options.valueOf("n"));
        } catch (NumberFormatException e) {
            System.err.println("FTL: -n expects a numeric argument!");
            showHelp();
            System.exit(1);
        }
    }
    if (options.has("o")) {
        oxp = (String) options.valueOf("o");
    }
    if (options.has("a")) {
        axp = (String) options.valueOf("a");
    }
    if (options.has("s")) {
        server = (String) options.valueOf("s");
    }
    if (options.has("?")) {
        showHelp();
        System.exit(0);
    }

    List arg = options.nonOptionArguments();
    if (arg.size() > 1) {
        System.err.println("FTL: only one source <DIR> argument is allowed!");
        showHelp();
        System.exit(1);
    }
    if (arg.size() == 1)
        dir = (String) arg.get(0);

    try {
        SaxonExtensionFunctions.registerAll(SaxonUtils.getProcessor().getUnderlyingConfiguration());
    } catch (Exception e) {
        System.err.println("ERR: couldn't register the Saxon extension functions: " + e);
        e.printStackTrace();
    }
    try {
        if (fdir == null)
            fdir = dir + "/fox";
        if (xdir == null)
            xdir = dir + "/fox-error";
        if (pdir == null)
            pdir = dir + "/policies";
        if (mdir == null)
            mdir = dir + "/management";
        XdmNode relsDoc = null;
        if (rfile != null && rfile.exists()) {
            relsDoc = SaxonUtils.buildDocument(new StreamSource(rfile));
            System.err.println("DBG: loaded[" + rfile.getAbsolutePath() + "]");
        } else {
            // create lookup document for relations
            XsltTransformer rels = SaxonUtils.buildTransformer(Main.class.getResource("/cmd2rels.xsl")).load();
            rels.setParameter(new QName("ext"), new XdmAtomicValue(cext));
            rels.setParameter(new QName("dir"), new XdmAtomicValue("file:" + dir));
            rels.setSource(new StreamSource(Main.class.getResource("/null.xml").toString()));
            XdmDestination dest = new XdmDestination();
            rels.setDestination(dest);
            rels.transform();
            relsDoc = dest.getXdmNode();
            if (rfile != null) {
                TransformerFactory.newInstance().newTransformer().transform(relsDoc.asSource(),
                        new StreamResult(rfile));
                System.err.println("DBG: saved[" + rfile.getAbsolutePath() + "]");
            }
        }
        if (relationCheck) {
            // Check the relations
            XsltTransformer rcheck = SaxonUtils.buildTransformer(Main.class.getResource("/checkRels.xsl"))
                    .load();
            rcheck.setParameter(new QName("rels-doc"), relsDoc);
            rcheck.setSource(new StreamSource(Main.class.getResource("/null.xml").toString()));
            XdmDestination dest = new XdmDestination();
            rcheck.setDestination(dest);
            rcheck.transform();
        }
        //System.exit(0);
        // CMDI 2 FOX
        // create the fox dirs
        FileUtils.forceMkdir(new File(fdir));
        FileUtils.forceMkdir(new File(xdir));
        Collection<File> inputs = FileUtils.listFiles(new File(dir), new String[] { cext }, true);
        // if there is a CMD 2 DC or 2 other XSLT include it
        XsltExecutable cmd2fox = null;
        if (dfile != null || mfile != null) {
            XsltTransformer inclCMD2DC = SaxonUtils
                    .buildTransformer(Main.class.getResource("/inclCMD2DCother.xsl")).load();
            inclCMD2DC.setSource(new StreamSource(Main.class.getResource("/cmd2fox.xsl").toString()));
            if (dfile != null)
                inclCMD2DC.setParameter(new QName("cmd2dc"),
                        new XdmAtomicValue("file://" + (new File(dfile)).getAbsolutePath()));
            if (mfile != null)
                inclCMD2DC.setParameter(new QName("cmd2other"),
                        new XdmAtomicValue("file://" + (new File(mfile)).getAbsolutePath()));
            XdmDestination destination = new XdmDestination();
            inclCMD2DC.setDestination(destination);
            inclCMD2DC.transform();
            cmd2fox = SaxonUtils.buildTransformer(destination.getXdmNode());
        } else
            cmd2fox = SaxonUtils.buildTransformer(Main.class.getResource("/cmd2fox.xsl"));
        int err = 0;
        int i = 0;
        int s = inputs.size();
        for (File input : inputs) {
            i++;
            if (!input.isHidden() && !input.getAbsolutePath().matches(".*/(corpman|sessions)/.*")) {
                try {
                    XsltTransformer fox = cmd2fox.load();
                    //fox.setParameter(new QName("rels-uri"), new XdmAtomicValue("file:"+map.getAbsolutePath()));
                    fox.setParameter(new QName("rels-doc"), relsDoc);
                    fox.setParameter(new QName("conversion-base"), new XdmAtomicValue(dir));
                    if (idir != null)
                        fox.setParameter(new QName("import-base"), new XdmAtomicValue(idir));
                    fox.setParameter(new QName("fox-base"), new XdmAtomicValue(fdir));
                    fox.setParameter(new QName("lax-resource-check"), new XdmAtomicValue(laxResourceCheck));
                    if (collsDoc != null)
                        fox.setParameter(new QName("collections-map"), collsDoc);
                    if (server != null)
                        fox.setParameter(new QName("repository"), new XdmAtomicValue(server));
                    if (oxp != null)
                        fox.setParameter(new QName("oai-include-eval"), new XdmAtomicValue(oxp));
                    if (axp != null) {
                        fox.setParameter(new QName("always-collection-eval"), new XdmAtomicValue(axp));
                        fox.setParameter(new QName("always-compound-eval"), new XdmAtomicValue(axp));
                    }
                    if (bdir != null)
                        fox.setParameter(new QName("icon-base"), new XdmAtomicValue(bdir));
                    if (pdir != null)
                        fox.setParameter(new QName("policies-dir"), new XdmAtomicValue(pdir));
                    if (mdir != null)
                        fox.setParameter(new QName("management-dir"), new XdmAtomicValue(mdir));
                    fox.setParameter(new QName("create-cmd-object"), new XdmAtomicValue(createCMDObject));
                    fox.setSource(new StreamSource(input));
                    XdmDestination destination = new XdmDestination();
                    fox.setDestination(destination);
                    fox.transform();
                    String fid = SaxonUtils.evaluateXPath(destination.getXdmNode(), "/*/@PID").evaluateSingle()
                            .getStringValue();
                    File out = new File(fdir + "/" + fid.replaceAll("[^a-zA-Z0-9]", "_") + "_CMD.xml");
                    if (out.exists()) {
                        System.err.println(
                                "ERR:" + i + "/" + s + ": FOX[" + out.getAbsolutePath() + "] already exists!");
                        out = new File(xdir + "/lat-error-" + (++err) + ".xml");
                        System.err.println("WRN:" + i + "/" + s + ": saved to FOX[" + out.getAbsolutePath()
                                + "] instead!");
                    }
                    TransformerFactory.newInstance().newTransformer()
                            .transform(destination.getXdmNode().asSource(), new StreamResult(out));
                    System.err.println("DBG:" + i + "/" + s + ": created[" + out.getAbsolutePath() + "]");
                } catch (Exception e) {
                    System.err.println("ERR:" + i + "/" + s + ": " + e);
                    System.err
                            .println("WRN:" + i + "/" + s + ": skipping file[" + input.getAbsolutePath() + "]");
                }
            }
        }
        if (ndir > 0) {
            int n = 0;
            int d = 0;
            inputs = FileUtils.listFiles(new File(fdir), new String[] { "xml" }, true);
            i = 0;
            s = inputs.size();
            for (File input : inputs) {
                i++;
                if (n == ndir)
                    n = 0;
                n++;
                FileUtils.moveFileToDirectory(input, new File(fdir + "/" + (n == 1 ? ++d : d)), true);
                if (n == 1)
                    System.err.println("DBG:" + i + "/" + s + ": moved to dir[" + fdir + "/" + d + "]");
            }
        }
        if (validateFOX) {
            SchemAnon tron = new SchemAnon(Main.class.getResource("/foxml1-1.xsd"), "ingest");
            inputs = FileUtils.listFiles(new File(fdir), new String[] { "xml" }, true);
            i = 0;
            s = inputs.size();
            for (File input : inputs) {
                i++;
                // validate FOX
                if (!tron.validate(input)) {
                    System.err
                            .println("ERR:" + i + "/" + s + ": invalid file[" + input.getAbsolutePath() + "]");
                    for (Message msg : tron.getMessages()) {
                        System.out.println("" + (msg.isError() ? "ERR: " : "WRN: ") + i + "/" + s + ": "
                                + (msg.getLocation() != null ? "at " + msg.getLocation() : ""));
                        System.out.println(
                                "" + (msg.isError() ? "ERR: " : "WRN: ") + i + "/" + s + ": " + msg.getText());
                    }
                } else
                    System.err.println("DBG:" + i + "/" + s + ": valid file[" + input.getAbsolutePath() + "]");
            }
        }
    } catch (Exception ex) {
        System.err.println("FTL: " + ex);
        ex.printStackTrace(System.err);
    }
}