1 package net.nutch.protocol.ftp; 2 3 import java.io.BufferedReader ; 4 import java.io.StringReader ; 5 import java.io.IOException ; 6 7 import java.util.logging.Logger ; 8 import org.apache.commons.net.ProtocolCommandEvent; 9 import org.apache.commons.net.ProtocolCommandListener; 10 11 16 public class PrintCommandListener implements ProtocolCommandListener 17 { 18 private Logger __logger; 19 20 public PrintCommandListener(Logger logger) 21 { 22 __logger = logger; 23 } 24 25 public void protocolCommandSent(ProtocolCommandEvent event) { 26 try { 27 __logIt(event); 28 } catch (IOException e) { 29 __logger.info("PrintCommandListener.protocolCommandSent(): "+e); 30 } 31 } 32 33 public void protocolReplyReceived(ProtocolCommandEvent event) { 34 try { 35 __logIt(event); 36 } catch (IOException e) { 37 __logger.info("PrintCommandListener.protocolReplyReceived(): "+e); 38 } 39 } 40 41 private void __logIt(ProtocolCommandEvent event) throws IOException { 42 BufferedReader br = 43 new BufferedReader (new StringReader (event.getMessage())); 44 String line; 45 while ((line = br.readLine()) != null) { 46 __logger.info("ftp> "+line); 47 } 48 } 49 } 50 | Popular Tags |