STUDY MATERIAL

Class : III B.Sc Computer Science Subject : Internet and Java Programming Unit : V

UTILITIES AND APPLETS : - Dictionary class – Hashtable – String Tokenizer – Runtime – System class – Comparison – Input and Output – File – Directory – Filenamefilter – File Streams – Applets – HTML Applet tag – Order of applet initialization – Sizing graphics – Simple graphics methods – Drawline – DrawArc – Font Manipulation – Simple Image loader – Image Observer – Summary

DICTIONARY CLASS It is an abstract class in java.util package. This class represents key and value pairs. Given a key and a value, you can store the value in Dictionary object. Once the value is stored you can retrieve it using the key. It is an obsolete class which is superceded by Map class.

The methods in Dictionary class

Method Description

Enumeration elements() Returns an enumeration of the values c contained in the Dictionary boolean isEmpty() Returns true if the dictionary is empty and false if it contains atleast one key

Enumeration keys() Returns an enumeration of keys contained in the dictionary

Object put(Object key Object value) Inserts a key and its value into the dictionary. Returns null if the key is not already in the dictionary; returns previous value associated with key if key is already present

Object remove(Object key) Removes key and its value int size() Returns the number of entries in the dictionary HASHTABLE CLASS This class is in java.util package and gives a concrete implementation for the Dictionary class. Hashtable also contains key and value pairs. The key’s hash code is used as an index at which the value is stored. The constructors for Hashtable for the following format 1. Hashtable () 2. Hashtable(int size) 3. Hashtable(int size, int fillratio)

The first version creates a default constructor. The second version creates a hashable with an initial size specified by size. The third version creates a hashable with an initial size and fill ratio specified by fillratio. it how full the hashtable can be before it is resized.

Method Desciption void clear() Resets and empties the hashtable bolean contains(Object value) Returns true if some value equal to value exists within the hash table. Returns false if the value is not found

Enumeration elements() Returns an enumeration of the values contained in the hash table

Object get(Object key) Returns the object that contains the value associated with key. If key is not found a null object is returned boolean isEmpty() Returns true if the hash table is empty, returns false if it contains atleast one key void rehash() Increases the size of the hash table and rehashes all of its key int size() Returns the number of entries in the hash table

Object remove(Object key) Removes key and its value. Returns the value associated with the key.

STRINGTOKENIZER The division of text into a set of discrete parts or Tokens is called as Parsing