hey guys i m devloping an application to read directories and subdirectories and files so this works perfectly
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package avd;
import java.io.File;
/**
*
* @author USER
*/
public class arborescence {
private String initialpath = "";
private Boolean recursivePath = false;
public int filecount = 0;
public int dircount = 0;
/**
* Constructeur
* @param path chemin du répertoire
* @param subFolder analyse des sous dossiers
*/
public arborescence(String path, Boolean subFolder) {
super();
this.initialpath = path;
this.recursivePath = subFolder;
}
public void list() {
this.listDirectory(this.initialpath);
}
private void listDirectory(String dir) {
File file = new File(dir);
File[] files = file.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory() == true) {
System.out.println("Dossier: " + files[i].getAbsolutePath());
FirstWindow.lblRepertoire.setText(files[i].getAbsolutePath());
this.dircount++;
} else {
System.out.println(" Fichier: " + files[i].getName());
FirstWindow.lblFile.setText(files[i].getAbsolutePath());
this.filecount++;
}
if (files[i].isDirectory() == true && this.recursivePath == true) {
this.listDirectory(files[i].getAbsolutePath());
}
}
}
}
}
and in the main Class i ve this
public void scanfiles(){
String pathToExplore = fileName;
arborescence arbo = new arborescence(pathToExplore, true);
Long start = System.currentTimeMillis();
arbo.list();
System.out.println("----------");
System.out.println("Analyse de " + pathToExplore + " en " + (System.currentTimeMillis() - start) + " mses");
lbltime.setText(Integer.toString((int) (System.currentTimeMillis() - start)));
System.out.println(arbo.dircount + " dossiers");
lblCountRep.setText(Integer.toString(arbo.dircount));
System.out.println(arbo.filecount + " fichiers");
lblCountFiles.setText(Integer.toString(arbo.filecount));
}
The Problem that in the Label "Repertoire" it shows me that the last one i wanna that it show me every one instatly like when the antivirus scan your files you see what it's scanning can we do that ?
is
some
text` - Been working since Java 1.3 :) – MadProgrammer Aug 03 '15 at 12:52