Package collections
Class CollectionExample
- java.lang.Object
-
- collections.CollectionExample
-
public class CollectionExample extends java.lang.Object
Example for theCollection
interfaces.Wraps a collection and performs simple i/o.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.lang.String>
c
Wrapped 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 void
dump()
Dumps collection to the console.java.util.Collection
getCollection()
Returns wrapped collection.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.int
read(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.IOException
Reads 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
-
-