public void getAllSub(String str) {
Set<String> result = new HashSet<String>();
int length = str.length();
int maxlength = length/2;
for (int i = 1; i <= maxlength; i++) {
for (int j = 0; j+i < length; j++) {
String target = str.substring(j, j+i);
String after = str.replaceAll(target, "");
if(length > (after.length()+target.length())){
result.add(target);
}
}
}
for (String string : result) {
System.out.println(string);
}
}