public final class WordLists extends Object
Modifier and Type | Field and Description |
---|---|
static Comparator<String> |
CASE_INSENSITIVE_COMPARATOR
Case insensitive comparator.
|
static Comparator<String> |
CASE_SENSITIVE_COMPARATOR
Case sensitive comparator.
|
static int |
NOT_FOUND
Index returned when word not found by binary search.
|
Modifier and Type | Method and Description |
---|---|
static int |
binarySearch(WordList wordList,
String word)
Performs a binary search of the given word list for the given word.
|
static ArrayWordList |
createFromReader(Reader[] readers)
Creates a case-sensitive
ArrayWordList by reading the contents of the given readers. |
static ArrayWordList |
createFromReader(Reader[] readers,
boolean caseSensitive)
Creates an
ArrayWordList by reading the contents of the given readers. |
static ArrayWordList |
createFromReader(Reader[] readers,
boolean caseSensitive,
ArraySorter sorter)
Creates an
ArrayWordList by reading the contents of the given file with support for sorting file contents. |
static void |
readWordList(Reader reader,
List<String> words)
Reads words, one per line, from a reader into the given word list.
|
static void |
readWords(InputStream in,
String charset,
List<String> words)
Reads words, one per line, from an input stream into the given word list.
|
static void |
readWords(Reader reader,
List<String> words)
Reads words, one per line, from a reader into the given word list.
|
static void |
readZippedWords(InputStream in,
String charset,
String regex,
List<String> words)
Reads words, one per line, from an input stream into the given word list.
|
public static final Comparator<String> CASE_SENSITIVE_COMPARATOR
public static final Comparator<String> CASE_INSENSITIVE_COMPARATOR
public static final int NOT_FOUND
public static int binarySearch(WordList wordList, String word)
wordList
- to searchword
- to search forpublic static ArrayWordList createFromReader(Reader[] readers) throws IOException
ArrayWordList
by reading the contents of the given readers.readers
- array of readersIOException
- if an error occurs reading from a readerpublic static ArrayWordList createFromReader(Reader[] readers, boolean caseSensitive) throws IOException
ArrayWordList
by reading the contents of the given readers.readers
- array of readerscaseSensitive
- set to true to create case-sensitive word list (default), false otherwiseIOException
- if an error occurs reading from a readerpublic static ArrayWordList createFromReader(Reader[] readers, boolean caseSensitive, ArraySorter sorter) throws IOException
ArrayWordList
by reading the contents of the given file with support for sorting file contents.readers
- array of readerscaseSensitive
- set to true to create case-sensitive word list (default), false otherwisesorter
- to sort the input array withIOException
- if an error occurs reading from a readerpublic static void readWords(Reader reader, List<String> words) throws IOException
This method does not close the reader.
reader
- the reader to read words fromwords
- the list to which the words are addedIOException
- if an error occurspublic static void readWords(InputStream in, String charset, List<String> words) throws IOException
This method does not close the input stream.
in
- the input stream to read words fromcharset
- the charset used to decode text from the streamwords
- the list to which the words are addedIOException
- if an error occurspublic static void readZippedWords(InputStream in, String charset, String regex, List<String> words) throws IOException
This method does not close the input stream.
in
- the input stream containing compressed data to read words fromcharset
- the charset used to decode text from the streamregex
- a regular expression that is used to match the ZIP entry names to
determine which of the entries should be read, or null if all entries should be readwords
- the list to which the words are addedIOException
- if an error occurspublic static void readWordList(Reader reader, List<String> words) throws IOException
reader
- Reader containing words, one per line. The reader is closed on completion.words
- Destination word list.IOException
- on IO errors reading from reader.Copyright © 2003-2024 Virginia Tech. All Rights Reserved.