scg/ch14/core/TestDictionary

From FANG

Jump to: navigation, search

01 package scg.ch14.core;
02 
03 import scg.ch14.io.SansCommentFilterReader;
04 
05 import java.io.File;
06 import java.io.FileNotFoundException;
07 import java.io.FileReader;
08 import java.util.Scanner;
09 
10 import scg.ch14.dictionary.Dictionary;
11 
12 /**
13  * Test the alias dictionary by reading in a file and printing out the
14  * contents of the dictionary.
15  */
16 public class TestDictionary {
17   /**
18    @param  args
19    */
20   public static void main(String[] args{
21     if (args.length > 0{
22       Scanner aliases = null;
23       try {
24         aliases = new Scanner(new SansCommentFilterReader(
25               new FileReader(new File(args[0]))));
26         Dictionary dictionary = new Dictionary(aliases);
27         System.out.println("=====================");
28         System.out.println("dictionary = \n" + dictionary);
29         System.out.println("=====================");
30       } catch (FileNotFoundException e{
31         System.err.println("Unable to open " + args[0] + " for input.");
32       } finally {
33         if (aliases != null{
34           aliases.close();
35         }
36       }
37     } else {
38       System.err.println("usage: java TestDictionary dictionaryFName");
39       System.err.println("       where dictanaryFName is a file");
40     }
41   }
42 }
43 
44 //Uploaded on Mon Mar 29 21:40:54 EDT 2010


Download/View scg/ch14/core/TestDictionary.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games