nntp.java
来自「apache推出的net包」· Java 代码 · 共 1,018 行 · 第 1/3 页
JAVA
1,018 行
return sendCommand(NNTPCommand.HELP); } /*** * A convenience method to send the NNTP IHAVE command to the server, * receive the reply, and return the reply code. * <p> * @param messageId The article identifier, * including the encapsulating < and > characters. * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int ihave(String messageId) throws IOException { return sendCommand(NNTPCommand.IHAVE, messageId); } /*** * A convenience method to send the NNTP LAST command to the server, * receive the reply, and return the reply code. * <p> * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int last() throws IOException { return sendCommand(NNTPCommand.LAST); } /*** * A convenience method to send the NNTP LIST command to the server, * receive the reply, and return the reply code. * <p> * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int list() throws IOException { return sendCommand(NNTPCommand.LIST); } /*** * A convenience method to send the NNTP NEXT command to the server, * receive the reply, and return the reply code. * <p> * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int next() throws IOException { return sendCommand(NNTPCommand.NEXT); } /*** * A convenience method to send the NNTP NEWGROUPS command to the server, * receive the reply, and return the reply code. * <p> * @param date The date after which to check for new groups. * Date format is YYMMDD * @param time The time after which to check for new groups. * Time format is HHMMSS using a 24-hour clock. * @param GMT True if the time is in GMT, false if local server time. * @param distributions Comma-separated distribution list to check for * new groups. Set to null if no distributions. * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int newgroups(String date, String time, boolean GMT, String distributions) throws IOException { StringBuffer buffer = new StringBuffer(); buffer.append(date); buffer.append(' '); buffer.append(time); if (GMT) { buffer.append(' '); buffer.append("GMT"); } if (distributions != null) { buffer.append(" <"); buffer.append(distributions); buffer.append('>'); } return sendCommand(NNTPCommand.NEWGROUPS, buffer.toString()); } /*** * A convenience method to send the NNTP NEWGROUPS command to the server, * receive the reply, and return the reply code. * <p> * @param newsgroups A comma-separated list of newsgroups to check for new * news. * @param date The date after which to check for new news. * Date format is YYMMDD * @param time The time after which to check for new news. * Time format is HHMMSS using a 24-hour clock. * @param GMT True if the time is in GMT, false if local server time. * @param distributions Comma-separated distribution list to check for * new news. Set to null if no distributions. * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int newnews(String newsgroups, String date, String time, boolean GMT, String distributions) throws IOException { StringBuffer buffer = new StringBuffer(); buffer.append(newsgroups); buffer.append(' '); buffer.append(date); buffer.append(' '); buffer.append(time); if (GMT) { buffer.append(' '); buffer.append("GMT"); } if (distributions != null) { buffer.append(" <"); buffer.append(distributions); buffer.append('>'); } return sendCommand(NNTPCommand.NEWNEWS, buffer.toString()); } /*** * A convenience method to send the NNTP POST command to the server, * receive the reply, and return the reply code. * <p> * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int post() throws IOException { return sendCommand(NNTPCommand.POST); } /*** * A convenience method to send the NNTP QUIT command to the server, * receive the reply, and return the reply code. * <p> * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int quit() throws IOException { return sendCommand(NNTPCommand.QUIT); } /*** * A convenience method to send the AUTHINFO USER command to the server, * receive the reply, and return the reply code. (See RFC 2980) * <p> * @param username A valid username. * @return The reply code received from the server. The server should * return a 381 or 281 for this command. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int authinfoUser(String username) throws IOException { String userParameter = "USER " + username; return sendCommand(NNTPCommand.AUTHINFO, userParameter); } /*** * A convenience method to send the AUTHINFO PASS command to the server, * receive the reply, and return the reply code. If this step is * required, it should immediately follow the AUTHINFO USER command * (See RFC 2980) * <p> * @param password a valid password. * @return The reply code received from the server. The server should * return a 281 or 502 for this command. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int authinfoPass(String password) throws IOException { String passParameter = "PASS " + password; return sendCommand(NNTPCommand.AUTHINFO, passParameter); } /*** * A convenience method to send the NNTP XOVER command to the server, * receive the reply, and return the reply code. * <p> * @param selectedArticles a String representation of the range of * article headers required. This may be an article number, or a * range of article numbers in the form "XXXX-YYYY", where XXXX * and YYYY are valid article numbers in the current group. It * also may be of the form "XXX-", meaning "return XXX and all * following articles" In this revision, the last format is not * possible (yet). * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int xover(String selectedArticles) throws IOException { return sendCommand(NNTPCommand.XOVER, selectedArticles); } /*** * A convenience method to send the NNTP XHDR command to the server, * receive the reply, and return the reply code. * <p> * @param header a String naming a header line (e.g., "subject"). See * RFC-1036 for a list of valid header lines. * @param selectedArticles a String representation of the range of * article headers required. This may be an article number, or a * range of article numbers in the form "XXXX-YYYY", where XXXX * and YYYY are valid article numbers in the current group. It * also may be of the form "XXX-", meaning "return XXX and all * following articles" In this revision, the last format is not * possible (yet). * @return The reply code received from the server. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int xhdr(String header, String selectedArticles) throws IOException { StringBuffer command = new StringBuffer(header); command.append(" "); command.append(selectedArticles); return sendCommand(NNTPCommand.XHDR, command.toString()); } /** * A convenience wrapper for the extended LIST command that takes * an argument, allowing us to selectively list multiple groups. * <p> * @param wildmat A wildmat (pseudo-regex) pattern. See RFC 2980 for * details. * @return the reply code received from the server. * @throws IOException */ public int listActive(String wildmat) throws IOException { StringBuffer command = new StringBuffer("ACTIVE "); command.append(wildmat); return sendCommand(NNTPCommand.LIST, command.toString()); }}/* Emacs configuration * Local variables: ** * mode: java ** * c-basic-offset: 4 ** * indent-tabs-mode: nil ** * End: ** */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?