Preview of data to process:
A
B
C
D
E
A,B
B,C
D,E
First part are nodes (points in software) and the second part (after empty line) are connections between nodes.
This file is loaded into two ArrayLists, which are separated (nodes and connections). All I need to do is merge (if one from nodes are same as in other connections) that connections between them.
public class ConsoleProcessor implements IntConsoleProcessor {
List<String> nodeA = new ArrayList<>();
List<String> nodeB = new ArrayList<>();
//From ArrayList split original data to two arrays (point A & B)
private void splitConnections(ArrayList<String> connections){
for(String str:connections)
{
String[] nodes = str.split(",");
nodeA.add(nodes[0]);
nodeB.add(nodes[1]);
}
//Console print for fast check of results
System.out.println(nodeA);
System.out.println(nodeB);
}
public void getResults(ArrayList<String> nodes, ArrayList<String> connections){
splitConnections(connections);
//need to continue somehow
}
}
As result I want to print out to console connections A,B,C (or something like that) and E,D (or D,E).
Wanted result:
Connection counter: 2
E,D
C,A,B
Actual result is only printing out nodeA and nodeB from connections
[A, B, E]
[B, C, D]