001: /*
002: * Created on 29/05/2004
003: *
004: * Swing Components - visit http://sf.net/projects/gfd
005: *
006: * Copyright (C) 2004 Igor Regis da Silva Simões
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: *
022: */
023: package br.com.igor.testes;
024:
025: import java.io.File;
026:
027: /**
028: *
029: * @autor: Igor Regis da Silva Simoes
030: */
031:
032: //dir1 = "c:\\lixo";
033: //dir2 = "c:\\lixo2";
034: public class TesteDir {
035:
036: /**
037: *
038: */
039: public TesteDir() {
040: super ();
041: }
042:
043: /**
044: * @param dir1
045: * @param dir2
046: */
047: public void compara(String dir1, String dir2) {
048: File um = new File(dir1);
049: File dois = new File(dir2);
050:
051: String[] dirs1 = um.list();
052: String[] dirs2 = dois.list();
053: boolean achou = false;
054:
055: if (dirs1 != null && dirs2 != null)
056: for (int i = 0; i < dirs1.length; i++) {
057: for (int j = 0; j < dirs2.length; j++) {
058: if (dirs1[i].equals(dirs2[j])) {
059: compara(um.getAbsolutePath() + "\\" + dirs1[i],
060: dois.getAbsolutePath() + "\\"
061: + dirs2[j]);
062: achou = true;
063: break;
064: } else
065: achou = false;
066: }
067: if (!achou)
068: System.out.println(um.getAbsolutePath() + "\\"
069: + dirs1[i] + " não foi encontrado");
070: }
071: }
072:
073: /**
074: * @param args
075: */
076: public static void main(String[] args) {
077: TesteDir t = new TesteDir();
078:
079: if (args.length != 2) {
080: System.out
081: .println("Numero de argumentos inválidos. Digite apenas o caminhos de dois diretórios.");
082: System.out.println("Ex.: TesteDir <dir1> <dir2>");
083: System.exit(-1);
084: }
085:
086: if (!(new File(args[0])).exists()) {
087: System.out
088: .println("O diretório " + args[0] + " não existe");
089: System.exit(-1);
090: }
091:
092: if (!(new File(args[1])).exists()) {
093: System.out
094: .println("O diretório " + args[1] + " não existe");
095: System.exit(-1);
096: }
097:
098: System.out.println("Comparando " + args[0] + " com " + args[1]);
099: System.out.println();
100: t.compara(args[0], args[1]);
101: System.out.println();
102: System.out.println("Comparando " + args[1] + " com " + args[0]);
103: System.out.println();
104: t.compara(args[1], args[0]);
105:
106: }
107: }
|