private static final String PATH = "";
private static final String DATA_FILE = PATH + "text.txt";
public static void main(String[] args) throws Exception {
File input = new File(DATA_FILE);
FileReader fileReader = new FileReader(input);
BufferedReader reader = new BufferedReader(fileReader);
String[] path = { "", "", "", "", "", "", "", "", "" };
int indent = 0;
makeIndent(reader, path, indent);
System.out.println("END");
}
private static void makeIndent(BufferedReader reader, String[] path, int indent) throws Exception {
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("{")) {
int bgnPos = line.indexOf("[") + 1;
int endPos = line.indexOf("]");
String tag = line.substring(bgnPos, endPos);
path[indent] = tag;
indent++;
makeIndent(reader, path, indent);
} else if (line.contains("}")) {
indent--;
path[indent] = "";
if (indent == 0) {
System.out.println("ZERO");
}
} else {
String[] data = line.trim().split(",");
for (String items : data) {
String[] item = items.replace("[", "").split("]", -1);
if (item.length != 2) {
System.out.println("WORNING!!!!!!");
}
StringBuilder builder = new StringBuilder();
for (String dir : path) {
builder.append(dir + "\t");
}
System.out.println(builder.toString() + item[0] + "\t" + item[1]);
}
}
}
}