You're recursing unconditionally:
public String getHex(String binary) {
StringBuilder hexBuilder = new StringBuilder();
int startIndex = 0;
int endIndex = 4;
while(true) {
hexBuilder.append(getHex(binary.substring(startIndex, endIndex)));
// Irrelevant
}
// Irrelevant
}
Basically aside from a little initialization, the first thing you do in your method is call it again. That call will the method again... which will call the method again, etc.
I suspect you meant to call getHexValue
, not getHex
... making the call not recursive at all. Currently you don't call getHexValue
at all.