1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @author : Salih Yurttas.
12 */
13
14
15package sl;
16
17import java.io.*;
18
19public class StringList {
20
21 static final int N = 16;
22
23 private String[] list;
24 private int count=0;
25
26 public StringList() {
27 list = new String[N];
28
29 for (int i=0; i<N; i++)
30 list[i] = "";
31 }
32
33 public StringList(final int size) {
34 list = new String[size];
35
36 for (int i=0; i<size; i++)
37 list[i] = "";
38 }
39
40 public StringList(final StringList l) {
41 int size = l.length();
42 list = new String[size];
43 count = l.count;
44
45 for (int i=0; i<size; i++)
46 list[i] = l.list[i];
47 }
48
49 public int length() {
50 return list.length;
51 }
52
53 public int size() {
54 return count;
55 }
56
57 public String getStringAt(final int i) {
58 return list[i];
59 }
60
61 public void setStringAt(final int i,
62 final String value) {
63 list[i] = value;
64 }
65
66 public void getStringList ()
67 throws IOException
68 {
69 DataInputStream dInS = new DataInputStream(System.in);
70 Reader kR = new BufferedReader(new InputStreamReader(dInS));
71 StreamTokenizer kTokens = new StreamTokenizer(kR);
72
73 System.out.print("inFileName : ");
74 System.out.flush();
75 kTokens.nextToken();
76 String inFileName = kTokens.sval;
77
78 FileInputStream fInS = new FileInputStream(inFileName);
79 Reader fR = new BufferedReader(new InputStreamReader(fInS));
80 StreamTokenizer fTokens = new StreamTokenizer(fR);
81
82 while(fTokens.nextToken() != fTokens.TT_EOF)
83 list[count++] = fTokens.sval;
84 }
85
86 public void putStringList ()
87 throws IOException
88 {
89 DataInputStream dInS = new DataInputStream(System.in);
90 Reader kR = new BufferedReader(new InputStreamReader(dInS));
91 StreamTokenizer kTokens = new StreamTokenizer(kR);
92
93 System.out.print("outFileName : ");
94 System.out.flush();
95 kTokens.nextToken();
96 String outFileName = kTokens.sval;
97
98 FileOutputStream fOutS = new FileOutputStream(outFileName);
99 PrintWriter pOutL = new PrintWriter(fOutS);
100
101 int size = count;
102
103 for (int i=0; i<size; i++)
104 pOutL.println(list[i]);
105
106 pOutL.close();
107 }
108
109}