Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.util
Class LineBreaker

    java.lang.Object
      umontreal.iro.lecuyer.util.LineBreaker

    public class LineBreaker

extends Object

Provides facilities to write multiple lines into output streams or writers, with automatic conversion of line separators. Strings are often generated using a string builder Strings are often generated by string builders before they are written into streams (e.g., files or console). When the generated strings contain multiple lines, the newline character (`n`) is often used as a line separator, but this does not always correspond to the platform's end-of-line separator. This class can be used to convert the line separators to the appropriate- platform-dependent, line separator before writing strings into streams.

Method Summary
`static String` | `getDefaultLineSeparator()` Returns the default, platform-dependent, line separator.
`static void` | `writeLines(BufferedWriter out, String str)` Similar to `String)`, for a buffered writer.
`static void` | `writeLines(PrintStream out, String str)` Similar to `String)`, for a print stream.
`static void` | `writeLines(PrintWriter out, String str)` Prints the string `out` using the correct platform-specific line separator.
`static
`<T extends Appendable> T`
` | `writeLines(T out, String str, String lineSeparator)` Similar to `String)`, for a generic appendable object, and a user-defined line separator `lineSeparator`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### writeLines

    public static void writeLines(PrintWriter out,
                                  String str)

  Prints the string `out` using the correct platform-specific line separator. This method splits the given string `str` using newline characters (`r`, `n`, and `rn`) as delimiters, and calls `PrintWriter.println(String)` for each part.

  Parameters:
    `out` - the print writer.
    `str` - the string to write.

### writeLines

    public static void writeLines(PrintStream out,
                                  String str)

  Similar to `String)`, for a print stream.

  Parameters:
    `out` - the print stream.
    `str` - the string.

### writeLines

    public static void writeLines(BufferedWriter out,
                                  String str)
                           throws IOException

  Similar to `String)`, for a buffered writer.

  Parameters:
    `out` - the buffered writer.
    `str` - the string.
  Throws:
    `if` - an I/O error occurs.
    `IOException`

### writeLines

    public static <T extends Appendable> T writeLines(T out,
                                                      String str,
                                                      String lineSeparator)
                                           throws IOException

  Similar to `String)`, for a generic appendable object, and a user-defined line separator `lineSeparator`.

  Parameters:
    `out` - the buffered writer.
    `str` - the string.
    `lineSeparator` - the line separator.
  Returns:
    the appendable `out`.
  Throws:
    `if` - an I/O error occurs.
    `IOException`

### getDefaultLineSeparator

    public static String getDefaultLineSeparator()

  Returns the default, platform-dependent, line separator.

  Returns:
    the default line separator.

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Richard Simard.