Group by classname in Console

27 Views Asked by At

I want to group my Console by classnames. Currently my Console prints stuff like this:

TraCheckController.java:
41: import de.ifdgmbh.wms.remote.model.views.VZone;
TraCheckController.java:
119:    *            {@link MapStringConverter} für {@link VZone} as {@link String}
TraCheckController.java:
417:    * {@link ListCellFactory} fuer die {@link VZone}en<br>

What do I have to change in my code in order to make my Console to look like this:

TraCheckController.java:
41: import de.ifdgmbh.wms.remote.model.views.VZone;
119:    *            {@link MapStringConverter} für {@link VZone} as {@link String}
417:    * {@link ListCellFactory} fuer die {@link VZone}en<br>

My code that handles the printing. It iterates trough every line of scripts and checks if some requirements are met or not:

while ((line = in.readLine()) != null) {
                    for (String className : viewFileClassStrings) {
                        // Check if file contains the classname and the file is not a comment or a import statement
                        int index = line.indexOf(className);
                        if(index < 0) {
                            continue;
                        }
                        if (line.toCharArray()[index - 1] == 'I') {
                            continue;
                        }
                        if (line.contains("Fields")) {
                            continue;
                        }
                        if (line.contains(className)) {
                            System.out.println(child.getName() + ":");
                            System.out.println(String.format("\t%d:\t%s", currentLine, line.trim()));
                        }
                    }
                    currentLine++;
                }
0

There are 0 best solutions below