public class StringArray extends Object
This class uses "" to represent a missing value (NaN).
| Modifier and Type | Field and Description |
|---|---|
String[] |
array
This is the main data structure.
|
protected int |
size
The number of active values (which may be different from the array's capacity).
|
| Constructor and Description |
|---|
StringArray()
A constructor for a capacity of 8 elements.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(String value)
This adds an item to the array (increasing 'size' by 1).
|
void |
ensureCapacity(long minCapacity)
This ensures that the capacity is at least 'minCapacity'.
|
static StringArray |
fromInputStream(InputStream inputStream,
String charset)
Reads the contents of
inputStream into a StringArray. |
String |
get(int index)
This gets a specified element.
|
int |
size()
Return the number of elements in the array.
|
protected int size
public String[] array
public StringArray()
public static StringArray fromInputStream(InputStream inputStream, String charset) throws IOException
inputStream into a StringArray. Each line of input will result in an element in
the array.
The specified stream remains open after this method returns.inputStream - a stream with line-based content.charset - the name of a supported charset.IOException - if an I/O error occurspublic int size()
public void add(String value)
value - the value to be added to the arraypublic void ensureCapacity(long minCapacity)
minCapacity - the minimum acceptable capacity.
minCapacity is type long, but >= Integer.MAX_VALUE will throw exception.public String get(int index)
index - 0 ... size-1Copyright © 1999–2014 UCAR/Unidata. All rights reserved.