|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecttribble.util.Strings
public abstract class Strings
Utility methods for string processing.
| Method Summary | |
|---|---|
static java.lang.String[] |
splitCSV(java.lang.String line)
Split a CSV text line into separate field values. |
static java.lang.String[] |
splitCSV(java.lang.String line,
boolean stripSp)
Split a CSV text line into separate field values. |
static java.lang.String |
toCSV(java.lang.String val)
Convert a string into a quoted CSV field value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String[] splitCSV(java.lang.String line)
splitCSV(line, true)
line - A string containing one or more text fields separated by commas (CSV).
public static java.lang.String[] splitCSV(java.lang.String line,
boolean stripSp)
Example
Consider the following CSV input text line:
Acme & Co., Inc.,"","A, B, and C",,"He said, ""Hello."""
The line above is split into the following strings (fields):
[0]: "Acme & Co."
[1]: " Inc."
[2]: ""
[3]: "A, B, and C"
[4]: ""
[5]: "He said, \"Hello.\""
line - A string containing one or more text fields separated by commas (CSV).stripSp - If true, leading and trailing spaces are stripped from each CSV field,
otherwise the fields are left unaltered.
java.lang.IllegalArgumentException - (unchecked)
Thrown if the CSV text line is malformed.public static java.lang.String toCSV(java.lang.String val)
Example
Consider the following input strings:
"Acme & Co., Inc."
"A, B, and C Company"
""
"He said, \"Hello.\""
These are converted into the following output CSV strings:
"\"Acme & Co., Inc.\""
"\"A, B, and C Company\""
"\"\""
"\"He said, \"\"Hello.\"\"\""
val - A string containing a text field value.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||