1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package examples;
17
18 import java.io.PrintWriter;
19 import org.apache.commons.net.ProtocolCommandEvent;
20 import org.apache.commons.net.ProtocolCommandListener;
21
22 /***
23 * This is a support class for some of the example programs. It is
24 * a sample implementation of the ProtocolCommandListener interface
25 * which just prints out to a specified stream all command/reply traffic.
26 * <p>
27 ***/
28
29 public class PrintCommandListener implements ProtocolCommandListener
30 {
31 private PrintWriter __writer;
32
33 public PrintCommandListener(PrintWriter writer)
34 {
35 __writer = writer;
36 }
37
38 public void protocolCommandSent(ProtocolCommandEvent event)
39 {
40 __writer.print(event.getMessage());
41 __writer.flush();
42 }
43
44 public void protocolReplyReceived(ProtocolCommandEvent event)
45 {
46 __writer.print(event.getMessage());
47 __writer.flush();
48 }
49 }