List of usage examples for org.apache.commons.net.io DotTerminatedMessageWriter DotTerminatedMessageWriter
public DotTerminatedMessageWriter(Writer output)
From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java
/*** * Post an article to the NNTP server. This method returns a * DotTerminatedMessageWriter instance to which the article can be * written. Null is returned if the posting attempt fails. You * should check {@link NNTP#isAllowedToPost isAllowedToPost() } * before trying to post. However, a posting * attempt can fail due to malformed headers. * <p>//from w w w .j a va2s.co m * You must not issue any commands to the NNTP server (i.e., call any * (other methods) until you finish writing to the returned Writer * instance and close it. The NNTP protocol uses the same stream for * issuing commands as it does for returning results. Therefore the * returned Writer actually writes directly to the NNTP connection. * After you close the writer, you can execute new commands. If you * do not follow these requirements your program will not work properly. * <p> * Different NNTP servers will require different header formats, but * you can use the provided * {@link org.apache.commons.net.nntp.SimpleNNTPHeader} * class to construct the bare minimum acceptable header for most * news readers. To construct more complicated headers you should * refer to RFC 822. When the Java Mail API is finalized, you will be * able to use it to compose fully compliant Internet text messages. * The DotTerminatedMessageWriter takes care of doubling line-leading * dots and ending the message with a single dot upon closing, so all * you have to worry about is writing the header and the message. * <p> * Upon closing the returned Writer, you need to call * {@link #completePendingCommand completePendingCommand() } * to finalize the posting and verify its success or failure from * the server reply. * <p> * @return A DotTerminatedMessageWriter to which the article (including * header) can be written. Returns null if the command fails. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. ***/ @Override public Writer postArticle() throws IOException { if (!NNTPReply.isPositiveIntermediate(post())) { return null; } return new DotTerminatedMessageWriter(_writer_); }
From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java
@Override public Writer forwardArticle(String articleId) throws IOException { if (!NNTPReply.isPositiveIntermediate(ihave(articleId))) { return null; }/*from w w w . j a va2s.com*/ return new DotTerminatedMessageWriter(_writer_); }
From source file:org.random_access.newsreader.nntp.CustomNNTPClient.java
public Writer postArticle() throws IOException { return !NNTPReply.isPositiveIntermediate(this.post()) ? null : new DotTerminatedMessageWriter(this._writer_); }