Here you can find the source of formatIndent(String whiteSpace)
public static String formatIndent(String whiteSpace)
//package com.java2s; public class Main { public static final String ATAB = String.valueOf('\u0009'); public static final String ASPACE = " "; /** Formats the indent so that it uses as many tabs as possible */ public static String formatIndent(String whiteSpace) { int tabs, spaces, newTabs; char chTemp; String strTemp, ret;/* ww w .ja v a 2s . c o m*/ tabs = 0; spaces = 0; newTabs = 0; ret = ""; for (int i = 0; i < whiteSpace.length(); i++) { chTemp = whiteSpace.charAt(i); strTemp = String.valueOf(chTemp); if (strTemp.equals(ASPACE)) spaces++; else if (strTemp.equals(ATAB)) tabs++; } if (spaces > 7) { newTabs = spaces / 8; spaces %= 8; } //Generate new indent for (int i = 0; i < tabs + newTabs; i++) ret += ATAB; for (int i = 0; i < spaces; i++) ret += ASPACE; return ret; } }