Home > Contents > Index >
Expanded TOC | Accordion TOC | Annotated TOC | Index
Utilities.words
Parses a string into a vector of words. The separator specifies the character that serves as the delimiter between words. White space is removed from both ends of each word parsed, using
String.trim()
.This method has two variants:
- words (Variant 1) accepts integers as delimiters.
- words (Variant 2) accepts strings as delimiters.
Utilities.words
Parses a string into a vector of words.
Syntax
public static final Vector words(String str, int sep)Parameters
str
- String of words to parse.
sep
- The separator character.
Description
The
words
method parses a string into a vector of words. The separator specifies the character that serves as the delimiter between words. White space is removed from both ends of each word parsed, usingString.trim()
.Returns
Returns a vector of words (may be empty).
Utilities.words
Parses a string into a vector of words.
Syntax
public static final Vector words(String str, String sep)Parameters
str
- String of words to parse.
sep
- String of separating characters.
Description
The
words
method parses a string into a vector of words. The separator specifies the string of characters that serves as the delimiter between words. Whitespace is removed from both ends of each word parsed, usingString.trim().
Returns
Returns a vector of words (may be empty).
Examples
The following code returns a vector containing the three strings "Jack", "Jill", "Little Alice".
Utilities.words( "Jack and Jill and Little Alice", "and" );
The following code returns an empty vector, not a vector containing two empty strings:
Utilities.words ( " and ", "and" );
Home > Contents > Index > ![]()
Oracle JAVA Reference
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.