/Users/lyon/j4p/src/futils/LineReader.java
|
1
2 package futils;
3
4 import java.util.Vector;
5
6 public class LineReader implements LineProcessor {
7 Vector v = new Vector();
8 PolymorphicProcessor pp = new
9 PolymorphicProcessor(this);
10
11 public String[] getLines() {
12 String s[] = new String[v.size()];
13 v.copyInto(s);
14
15 return s;
16 }
17
18 public static void main(String args[]) {
19 System.out.println(new LineReader());
20 }
21
22 public void process(String s) {
23 v.addElement(s);
24 }
25
26 public String toString() {
27 String s[] = getLines();
28 StringBuffer sb = new StringBuffer();
29 for (int i = 0; i < s.length; i++)
30 sb.append(s[i] + '\n');
31 return sb.toString();
32 }
33 }
34
35