Java Utililty Methods Tab Expand

List of utility methods to do Tab Expand

Description

The list of methods to do Tab Expand are organized into topic(s).

Method

StringexpandTabs(int ntabs)
expand Tabs
StringBuffer tabs = new StringBuffer();
for (int i = 0; i < ntabs; i++)
    tabs.append(' ');
return tabs.toString();
StringexpandTabs(String inputString, int numberOfSpaces)
expand Tabs
if (inputString.indexOf('\t') == -1)
    return inputString;
int inputStringLength = inputString.length();
StringBuffer buffer = new StringBuffer(inputStringLength);
String spaces = nCopies(numberOfSpaces, ' ');
for (int i = 0; i < inputStringLength; i++) {
    char c = inputString.charAt(i);
    if (c == '\t')
...
StringexpandTabs(String s, int tabSize)
expand Tabs
if (s == null)
    return null;
StringBuilder buf = new StringBuilder();
int col = 0;
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    switch (c) {
    case '\n':
...
StringexpandTabs(String str)
expand Tabs
return str.replace("\t", "    ");
StringBufferexpandTabs(String string, int tabSize)
Expands the given string's tabs according to the given tab size.
StringBuffer expanded = new StringBuffer();
for (int i = 0, n = string.length(), chars = 0; i < n; i++) {
    char ch = string.charAt(i);
    if (ch == '\t') {
        for (; chars < tabSize; chars++)
            expanded.append(' ');
        chars = 0;
    } else {
...
StringexpandTabs(String text, int tabSize)
expand Tabs
String rv = "";
if (text != null) {
    if (text.indexOf('\t') >= 0) {
        StringBuilder buf = new StringBuilder();
        int len = text.length();
        for (int i = 0; i < len; i++) {
            char ch = text.charAt(i);
            if (ch == '\t') {
...
StringexpandTabs(String text, int tabWidth)
Same as expandTabs(text, tabWidth, 0) .
return expandTabs(text, tabWidth, 0);