Class LineIter

java.lang.Object
com.github.sttk.linebreak.LineIter
All Implemented Interfaces:
Iterator<String>

public class LineIter extends Object implements Iterator<String>
LineIter is the class that outputs the given string line by line. This class can control the overall line width and the indentation from any desired line.
  • Constructor Details

    • LineIter

      public LineIter(String text, int lineWidth)
      Is the constructor that creates a LineIter instance which outputs the given string line by line.
      Parameters:
      text - A string to be output with line breaking.
      lineWidth - A width of the output lines.
  • Method Details

    • setIndent

      public void setIndent(String indent)
      Sets an indentation for the subsequent lines.
      Parameters:
      indent - A string to be used for indentation.
    • init

      public void init(String text)
      Re-initializes with an argument string for reusing this instance.
      Parameters:
      text - A string to be output with line breaking.
    • hasNext

      public boolean hasNext()
      Checks whether the remaining string exists or not.
      Specified by:
      hasNext in interface Iterator<String>
      Returns:
      True if the remaining string exists.
    • next

      public String next()
      Returns a string of the next line.
      Specified by:
      next in interface Iterator<String>
      Returns:
      A next line string.