Package collections
Class CollectionExample
- java.lang.Object
-
- collections.CollectionExample
-
public class CollectionExample extends java.lang.ObjectExample for theCollectioninterfaces.Wraps a collection and performs simple i/o.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.lang.String>cWrapped collection.
-
Constructor Summary
Constructors Constructor Description CollectionExample(java.util.Collection<java.lang.String> c)Creates a new collection wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump()Dumps collection to the console.java.util.CollectiongetCollection()Returns wrapped collection.static voidmain(java.lang.String[] args)Reads words from the file specified by the first command line argument and writes it to the console.intread(java.lang.String file)Reads specified file word-by-word into the collection.
-
-
-
Method Detail
-
read
public int read(java.lang.String file) throws java.io.IOExceptionReads specified file word-by-word into the collection.- Parameters:
file- file to read.- Returns:
- number of words read.
- Throws:
java.io.IOException- if an I/O error occurred.
-
dump
public void dump()
Dumps collection to the console.
-
getCollection
public java.util.Collection getCollection()
Returns wrapped collection.- Returns:
- wrapped collection.
-
main
public static void main(java.lang.String[] args)
Reads words from the file specified by the first command line argument and writes it to the console.- Parameters:
args- ignored
-
-