コード例 #1
1
ファイル: Util.java プロジェクト: w7cook/batch-javac
 /**
  * Given a string, replace all tabs with the appropriate number of spaces.
  *
  * @param tabLength the length of each tab.
  * @param s the String to scan.
  */
 public static void replaceTabs(int tabLength, StringBuilder s) {
   if (whitespace == null || whitespace.length() < tabLength)
     whitespace = String.format("%" + tabLength + "s", " ");
   int index = 0;
   while ((index = s.indexOf("\t", index)) != -1) {
     int spaceCount = tabLength - index % tabLength;
     s.replace(index, index + 1, whitespace.substring(0, spaceCount));
     index += spaceCount;
   }
 }