Util (Jericho HTML Parser 3.1)
Keywords: net.htmlparser.jericho.Util class

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.htmlparser.jericho
Class Util

    java.lang.Object
      Util

    public final class Util

extends java.lang.Object

Contains miscellaneous utility methods not directly associated with the HTML Parser library.

Method Summary
`static java.lang.String` | `getString(java.io.Reader reader)` Returns the text loaded from the specified `Reader` as a string.
`static void` | `outputCSVLine(java.io.Writer writer, java.lang.String[] values)` Outputs the specified array of strings to the specified `Writer` in the format of a line for a CSV file.

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

Method Detail

### getString

    public static java.lang.String getString(java.io.Reader reader)
                                      throws java.io.IOException

  Returns the text loaded from the specified `Reader` as a string.

  If a `null` argument is supplied to this method, an empty string is returned.

  To load text from an `InputStream`, use `getString(new InputStreamReader(inputStream,encoding))`.

  Parameters:
    `reader` - the `java.io.Reader` from which to load the text.
  Returns:
    the text loaded from the specified `java.io.Reader` as a string.
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### outputCSVLine

    public static void outputCSVLine(java.io.Writer writer,
                                     java.lang.String[] values)
                              throws java.io.IOException

  Outputs the specified array of strings to the specified `Writer` in the format of a line for a CSV file.

  "CSV" stands for Comma Separated Values. There is no formal specification for a CSV file, so there is significant variation in the way different applications handle issues like the encoding of different data types and special characters.

  Generally, a CSV file contains a list of records separated by line breaks, with each record consisting of a list of field values separated by commas. Each record in the file should contain the same number of field values, with the values at each position representing the same type of data in all the records. In this way the file can also be divided into columns, often with the first line of the file containing the column labels.

  Columns can have different data types such as text, numeric, date / time and boolean. A text value is often delimited with single (`'`) or double-quotes (`"`), especially if the value contains a comma, line feed, or other special character that is significant to the syntax. Encoding techniques for including quote characters themselves in text values vary widely. Values of other types are generally unquoted to distinguish them from text values.

  This method produces output that is readable by MS-Excel, conforming to the following rules:

  - All values are considered to be of type text, except for the static constants `Config.ColumnValueTrue` and `Config.ColumnValueFalse`, representing the boolean values `true` and `false` respectively.
  - All text values are enclosed in double-quotes.
  - Double-quote characters contained in text values are encoded using two consecutive double-quotes (`""`).
  - `null` values are represented as empty fields.
  - The end of each record is represented by a carriage-return / line-feed (CR/LF) pair.
  - Line breaks inside text values are represented by a single line feed (LF) character.

  Parameters:
    `writer` - the destination `java.io.Writer` for the output.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
  See Also:
    `FormFields.getColumnLabels()`, `FormFields.getColumnValues(Map)`

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD