View difference between Paste ID: qGNaqB9A and UpwcnBeN
SHOW: | | - or go back to the newest paste.
1
package com.epam.automation.input.main;
2
3
import java.io.File;
4
import java.io.FileNotFoundException;
5
import java.io.PrintWriter;
6
7
public class Program {
8
    public static void main(String[] args) throws FileNotFoundException {
9
        String path = "d:/Java/collections/collections/src/main/java/com/epam/automation/input/main";
10
        File file = new File(path);
11
        File fileForPrint = new File("d:/Java/collections/collections/src/main/java/com/epam/automation/input/main/structureFile");
12
        PrintWriter pw = new PrintWriter(fileForPrint);
13
        if (file.exists()) {
14
            if (file.isDirectory()) {
15
                pw.println(file.getName());
16
                writeStructure(file, pw, 0);
17
            }
18
            else {
19
                
20
            }
21
        }
22
        pw.close();
23
    }
24
25
    public static void writeStructure(File file, PrintWriter pw, int level) {
26
        File[] structure = file.listFiles();
27
        StringBuilder sb = new StringBuilder();
28
		String spaces = addSpaces(level, sb).toString();
29
        for (int i = 0; i < structure.length; i++) {
30-
                pw.println(("|---" + addSpaces(level, sb) + structure[i].getName()));
30+
31
                pw.println(spaces + "|---" + structure[i].getName());
32
                writeStructure(structure[i], pw, level + 1);
33-
                pw.println(("|   " + sb + structure[i].getName()));
33+
34
                pw.println(spaces  + "|   " + sb + structure[i].getName());
35
            }
36
        }
37
    }
38
39-
        for (int i = 0; i < level; i++) {
39+
40
        for (int i = 0; i < level * 4; i++) {
41
            sb.append(" ");
42
        }
43
        return sb;
44
    }
45
    public static void readFile () {
46
47
    }
48
}