Package org.jf.util

Class StringWrapper


  • public class StringWrapper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      StringWrapper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void printWrappedString​(java.io.PrintStream stream, java.lang.String string, int maxWidth)  
      static java.lang.String[] wrapString​(java.lang.String str, int maxWidth, java.lang.String[] output)
      Splits the given string into lines using on any embedded newlines, and wrapping the text as needed to conform to the given maximum line width.
      static java.lang.Iterable<java.lang.String> wrapStringOnBreaks​(java.lang.String string, int maxWidth)
      Splits the given string into lines of maximum width maxWidth.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringWrapper

        public StringWrapper()
    • Method Detail

      • wrapStringOnBreaks

        public static java.lang.Iterable<java.lang.String> wrapStringOnBreaks​(@Nonnull
                                                                              java.lang.String string,
                                                                              int maxWidth)
        Splits the given string into lines of maximum width maxWidth. The splitting is done using the current locale's rules for splitting lines.
        Parameters:
        string - The string to split
        maxWidth - The maximum length of any line
        Returns:
        An iterable of Strings containing the wrapped lines
      • wrapString

        public static java.lang.String[] wrapString​(@Nonnull
                                                    java.lang.String str,
                                                    int maxWidth,
                                                    @Nullable
                                                    java.lang.String[] output)
        Splits the given string into lines using on any embedded newlines, and wrapping the text as needed to conform to the given maximum line width. This uses and assumes unix-style newlines
        Parameters:
        str - The string to split
        maxWidth - The maximum length of any line
        output - If given, try to use this array as the return value. If there are more values than will fit into the array, a new array will be allocated and returned, while the given array will be filled with as many lines as would fit.
        Returns:
        The split lines from the original, as an array of Strings. The returned array may be larger than the number of lines. If this is the case, the end of the split lines will be denoted by a null entry in the array. If there is no null entry, then the size of the array exactly matches the number of lines. The returned lines will not contain an ending newline
      • printWrappedString

        public static void printWrappedString​(@Nonnull
                                              java.io.PrintStream stream,
                                              @Nonnull
                                              java.lang.String string,
                                              int maxWidth)