Hello fellow programmers!
I've made this
whitespaceIndent
method, for creating a indentation string out of whitespaces.
My goal was to create a method, that replaces tabs.
So fx, if I used tabs, this would be my output:
Directory Size
C:/Games 126 MB
C:/Program Files 259 MB
But if I used the
whitespaceIndent
method, this would be my output:
Directory Size
C:/Games 126 MB
C:/Program Files 259 MB
It's doing this by taking the total size of the indentation, and a x amount of removal indentation.
So in this case, the total size of the indentation would be between index 0 and the beginning index at
Size
. It when subtracts the length of
C:/Program Files
from the total indentation.
But now I'm wondering, is there a easier way of doing this?
If you know any, please let me know.
Thanks in advanced - Neven.
The code I'm referring to:
public static String whitespaceIndent(int total, int removal) {
String whitespace = "";
for (int i = 0; i < total - removal; i ++)
whitespace += " ";
return whitespace;
}