⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pop3client.java

📁 Pop3协议的java实现代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    public synchronized void pass( String in_password ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( in_password == null )        {            throw new IllegalArgumentException();        }        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_pass );        m_io.send( in_password, false );        m_pendingList.addElement( PASS_OBJ );        m_mustProcess = true;    }    /**    *Closes the connection with the server and expunges any deleted messages.    *Ends the session, purging deleted messages and logging the user    *out from the POP3 server. If issued in Authentication state,    *server closes connections. If issued in Transaction state,    *server goes into Update state and deletes marked messages,    *then quits.    *@exception IOException If an I/O error occurs.    *@see IPO3Sink#quit    *@see IPOP3Sink#error    *@see #delete    */    public synchronized void quit() throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.send( m_quit, false );        m_pendingList.addElement( QUIT_OBJ );        m_mustProcess = true;    }    /**    *Resets the state of the server by undeleting any deleted messages.    *Cancels the current mail transfer and all current processes,    *discards data, and clears all states.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#reset    *@see IPOP3Sink#error    */    public synchronized void reset() throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.send( m_rset, false );        m_pendingList.addElement( RSET_OBJ );        m_mustProcess = true;    }    /**    *Retrieves a message.	*@param in_messageNumber Number of message to retrieve.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#retrieve    *@see IPOP3Sink#retrieveComplete    *@see IPOP3Sink#retrieveStart    *@see IPOP3Sink#error    */    public synchronized void retrieve( int in_messageNumber ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_retr );        m_io.send(m_itoaBuffer, 0, m_common.itoa(in_messageNumber, m_itoaBuffer), false);        m_pendingList.addElement( RETR_OBJ );        m_currentMessageNumber = in_messageNumber;        m_mustProcess = true;    }    /**    *Sends an unsupported command to the server.    *Sends commands that are not supported by the Messaging Access SDK    *implementation of POP3.    *NOTE: This method is primarily intended to support extensions    *to the protocol to meet client application needs.	*@param in_command Raw command to send to the server.	*@param in_multiLine Identifies whether response is multiline or not.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#sendCommand    *@see IPOP3Sink#sendCommandStart    *@see IPOP3Sink#sendCommandComplete    *@see IPOP3Sink#error    */    public synchronized void sendCommand( String in_command, boolean in_multiLine ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( in_command == null )        {            throw new IllegalArgumentException();        }        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.send( in_command, false );        if ( in_multiLine )        {            m_pendingList.addElement( SENDCOMMAND_OBJ );        }        else        {            m_pendingList.addElement( SENDCOMMANDA_OBJ );        }        m_mustProcess = true;    }    /**    *Gets the status of the mail drop.    *Returns the number of messages and octet size of the mail drop.    *Always returns message octet count.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#stat    *@see IPOP3Sink#error    */    public synchronized void stat() throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.send( m_stat, false );        m_pendingList.addElement( STAT_OBJ );        m_mustProcess = true;    }    /**    *Retrieves headers plus the specified number of lines from the body.	*@param in_messageNumber Number of message to retrieve.	*@param in_lines Number of lines of the message body to return.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#topStart    *@see IPOP3Sink#top    *@see IPOP3Sink#topComplete    *@see IPOP3Sink#error    */    public synchronized void top( int in_messageNumber, int in_lines ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_top );        m_io.write( m_itoaBuffer, 0, m_common.itoa(in_messageNumber, m_itoaBuffer) );        m_io.write( m_space );        m_io.send( m_itoaBuffer, 0, m_common.itoa(in_lines, m_itoaBuffer), false );        m_pendingList.addElement( TOP_OBJ );        m_currentMessageNumber = in_messageNumber;        m_mustProcess = true;    }    /**    *Lists all messages with their unique-ids.    *POP3 includes two forms of uidList(). This form goes through all    *the messages in the mailbox and generates a list of messages    *with their unique ids.    *The other form takes the message number of the message to    *list as an argument.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#uidList    *@see IPOP3Sink#uidListStart    *@see IPOP3Sink#uidListComplete    *@see IPOP3Sink#error    */    public synchronized void uidList() throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.send( m_uidl, false );        m_pendingList.addElement( UIDL_OBJ );        m_mustProcess = true;    }    /**    *Lists a message with its unique id.    *POP3 includes two forms of uidList(). This form takes the message number of the message to    *list with its unique id as an argument.    *The other form goes through all    *the messages in the mailbox and generates a list of messages.	*@param in_messageNumber Number of message for which to return a unique id. .    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#uidList    *@see IPOP3Sink#uidListStart    *@see IPOP3Sink#uidListComplete    *@see IPOP3Sink#error    */    public synchronized void uidList( int in_messageNumber ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_uidl );        m_io.send( m_itoaBuffer, 0, m_common.itoa(in_messageNumber, m_itoaBuffer), false );        m_pendingList.addElement( UIDLA_OBJ );        m_mustProcess = true;    }    /**    *Enters a username.    *Identifies the user or mail drop by name to the server;    *the server returns a known or unknown response.	*@param in_user Name of the user's maildrop.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#user    *@see IPOP3Sink#error    *@see #pass    */    public synchronized void user( String in_user ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( in_user == null )        {            throw new IllegalArgumentException();        }        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_user );        m_io.send( in_user, false );        m_pendingList.addElement( USER_OBJ );        m_mustProcess = true;    }    /**    *Returns a list of authenticated users.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#xAuthList    *@see IPOP3Sink#xAuthListStart    *@see IPOP3Sink#xAuthListComplete    *@see IPOP3Sink#error    */    public synchronized void xAuthList() throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.send( m_xauthlist, false );        m_pendingList.addElement( XAUTHLIST_OBJ );        m_mustProcess = true;   }    /**    *Returns a list of authenticated users for a specified message.    *@param in_messageNumber The message number.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#xAuthList    *@see IPOP3Sink#xAuthListStart    *@see IPOP3Sink#xAuthListComplete    *@see IPOP3Sink#error    */    public synchronized void xAuthList( int in_messageNumber ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_xauthlist );        m_io.send(m_itoaBuffer, 0, m_common.itoa(in_messageNumber, m_itoaBuffer), false);        m_pendingList.addElement( XAUTHLISTA_OBJ );        m_mustProcess = true;    }    /**    *Gets the email address of the sender of the specified message.    *Gets the email address of the sender of the specified message.    *Sends the XSENDER [arg] POP3 protocol command.	*@param in_messageNumber Number of the message.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#xSender    *@see IPOP3Sink#error    */    public synchronized void xSender( int in_messageNumber ) throws IOException    {        ///////////////////////////////////////////////////////////////////////        // Error checking before proceeding with command.        ///////////////////////////////////////////////////////////////////////        if ( m_mustProcess )        {            throw new POP3Exception(errProcessResponses);        }        m_io.write( m_xsender );        m_io.send(m_itoaBuffer, 0, m_common.itoa(in_messageNumber, m_itoaBuffer), false);        m_pendingList.addElement( XSENDER_OBJ );        m_mustProcess = true;    }    /**    *Reads in responses from the server and invokes the appropriate sink methods.    *Processes the server responses for API commands. Invokes the    *callback methods provided by the user for all responses that    *are available at the time of execution.    *NOTE: If a timeout occurs, the user can continue by calling processResponses() again.	*@return int The number of responses processed.    *@exception POP3ServerException If a server response error occurs.    *@exception InterruptedIOException If a time-out occurs.    *@exception IOException If an I/O error occurs.    *@see IPOP3Sink#error    */    public void processResponses() throws IOException    {        synchronized(m_responseMessage)        {            try            {                Integer l_commandType;                m_io.flush();                ///////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -