import java.io.*;

public class Hauptklasse {
	
	class Statistik {
		public int countFiles=0;
		public long sizeOfFiles=0;		
		public Statistik(int countFiles, long sizeOfFiles) {
			this.countFiles = countFiles;
			this.sizeOfFiles = sizeOfFiles;
		}
	}

	private Statistik showItemsInPath(String path) {
		System.out.println("\npath: " + path);
		File dir = new File(path);
		File[] items = dir.listFiles();
		int countFiles=0;
		long sizeOfFiles=0;
		for (File file : items) {
			if (file.isFile()) {
				System.out.println(" " + file.getName());
				// hier wurde eine neue Datei gefunden
				countFiles = countFiles +1;
				sizeOfFiles = sizeOfFiles +	file.length();
			}
		}
		for (File file : items) {
			if (file.isDirectory()) {
				System.out.println(" >" + file.getName());
				Statistik stat = showItemsInPath(file.getAbsolutePath());
				countFiles+=stat.countFiles;
				sizeOfFiles+=stat.sizeOfFiles;
			}
		}
		return new Statistik(countFiles,sizeOfFiles); 
	} // showItemsInPath

	private void explorer() {
		String path = "c:\\prog++\\";
		Statistik stat = showItemsInPath(path);
		System.out.println("anzFiles: "+stat.countFiles+
				"\nDateigrößen: "+stat.sizeOfFiles);
	}

	private Hauptklasse() {
	}

	public static void main(String[] args) {
		Hauptklasse instanz = new Hauptklasse();
		instanz.explorer();
	}

}
