The following code demonstrates a POP3 client which is used for retrieving mail content. Fill in the
Question:
The following code demonstrates a POP3 client which is used for retrieving mail content. Fill in the missing code. 1 /* imports ommitted */ 2 public class POP3Client { 3 private ___(a)___ [1] client ; 4 private BufferedReader in; 5 private BufferedWriter out ; 6 private static final int PORT = ___ (b)___ [1]; 7 public void connect ( String host , int port ) { 8 try { 9 client = /* OMMITTED */; 10 client . connect (new InetSocketAddress (host , port ) ) ; 11 in = new BufferedReader ( 12 new InputStreamReader ( ___________ (c) _______________ [1]) ) ; 13 out = new BufferedWriter ( 14 new OutputStreamWriter ( __________ (d) ______________ [1]) ) ; 15 readResponseLine () ; 16 } catch (/* OMMITTED */) { 17 System .err . println (io. getMessage () ) ; 18 } Page 3 of 5 Computer Science 2B Semester Test I 2020-09-01 19 } 20 public void connect ( String host ) { 21 connect (host , PORT ) ; 22 } 23 public boolean isConnected () { 24 return client != null && client . isConnected () ;} 25 public void disconnect () { 26 try { 27 if (! isConnected () ) 28 throw new IllegalStateException (" Not connected to a host ") ; 29 _________ (e) ____________ [1]; 30 in = null ; 31 out = null ; 32 } catch (/* OMMITTED */) { 33 System .err . println (io. getMessage () ) ; 34 } 35 } 36 protected String readResponseLine () { 37 try { 38 String response = ________ (f) __________ [1]; 39 return response ; 40 } catch (/* OMMITTED */) { 41 System .err . println (io. getMessage () ) ; 42 return io. getMessage () ; 43 } } 44 protected String sendCommand ( String command ) { 45 try { 46 out. write ( command + " ") ; 47 _____ (g) ______ [1]; 48 return readResponseLine () ; 49 } catch ( _______ (h) ________ [1]) { 50 System .err . println (io. getMessage () ) ; 51 return io. getMessage () ; 52 } 53 } 54 public void login ( String username , String password ) { 55 sendCommand (" USER " + username ) ; 56 ____________ (i) __________________ [1]; 57 } 58 public void logout () { 59 _______ (j) __________ [1]; 60 } 61 protected String getMessage (int messageNumber ) { 62 String response = sendCommand (" RETR " + messageNumber ) ; 63 // process body 64 StringBuilder bodyBuilder = new StringBuilder () ; 65 while (!( response = readResponseLine () ) . equals (".") ) { 66 bodyBuilder . append ( response + " ") ; 67 } 68 return new String ( bodyBuilder ) ; 69 } 70 }
Income Tax Fundamentals 2019
ISBN: 9781337703062
37th Edition
Authors: Gerald E. Whittenburg, Steven Gill