Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package listdir;
- import java.io.*;
- /**
- *
- * @author KSinditski
- */
- public class ListDir {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- File BaseDir = new File("E:\\JavaTest");
- String[] SubBaseDir = BaseDir.list();
- if (SubBaseDir == null) {
- System.out.println("Panic!");
- } else {
- System.out.println("Total dir and files in " + BaseDir + ": " + SubBaseDir.length);
- for (int i = 0; i < SubBaseDir.length; i++) {
- File SubBaseFile = new File(BaseDir + "/" + SubBaseDir[i]);
- if (SubBaseFile.isFile()) {
- System.out.println(SubBaseDir[i] + " is FILE " + "Size: " + SubBaseFile.length() + "B");
- } else {
- System.out.println(SubBaseDir[i] + " is DIR.");
- System.out.println("Entering " + SubBaseDir[i] + "...");
- System.out.println("..");
- System.out.println(".");
- // Сюда воткнуть предыдущий цикл.
- // Чтобы еще раз выполнялось public static void main(String[] args) и в качестве аргументов
- // ему передать SubBaseDir[i]
- // А E:\\JavaTest задать раньше, например после public class ListDir
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment