Class StringUtils

Object
StringUtils

public class StringUtils extends Object
Contains methods for working with Strings.
Since:
1.8
Author:
LazyWizard
  • Method Details

    • wrapString

      public static String wrapString(String toWrap, int maxLineLength)
      Word-wraps a String (ensures it fits within a certain width). Note: this does not work properly with text containing tab characters (\t).
      Parameters:
      toWrap - The String to be word-wrapped.
      maxLineLength - How long a line can reach before it's split in two. Must be at least 2, otherwise it will return an empty String.
      Returns:
      toWrap wrapped to maxLineLength width.
      Since:
      1.8
    • indent

      public static String indent(String toIndent, String indentWith)
      Prepends every line of a String with another String.
      Parameters:
      toIndent - The String to be indented.
      indentWith - The String to prefix each line with. For example, a bulleted list could be created by passing in " * ".
      Returns:
      toIndent with every line prepended with indentWith.
      Since:
      1.8