Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
commons-net.jar Source Code
commons-net.jar is the bytecode of Apache Commons Net library, which implements the client side of many basic Internet protocols.
Apache Commons Net Source Code files are provided in the binary packge (commons-net-3.8.0-bin.zip). You can download it at Apache Commons Net Website.
The source code of commons-net-3.8.0.jar is provided below:
✍: FYIcenter
⏎ org/apache/commons/net/io/DotTerminatedMessageWriter.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.net.io; import java.io.IOException; import java.io.Writer; /** * DotTerminatedMessageWriter is a class used to write messages to a * server that are terminated by a single dot followed by a * <CR><LF> * sequence and with double dots appearing at the begining of lines which * do not signal end of message yet start with a dot. Various Internet * protocols such as NNTP and POP3 produce messages of this type. * <p> * This class handles the doubling of line-starting periods, * converts single linefeeds to NETASCII newlines, and on closing * will send the final message terminator dot and NETASCII newline * sequence. * * */ public final class DotTerminatedMessageWriter extends Writer { private static final int NOTHING_SPECIAL_STATE = 0; private static final int LAST_WAS_CR_STATE = 1; private static final int LAST_WAS_NL_STATE = 2; private int state; private Writer output; /** * Creates a DotTerminatedMessageWriter that wraps an existing Writer * output destination. * * @param output The Writer output destination to write the message. */ public DotTerminatedMessageWriter(final Writer output) { super(output); this.output = output; this.state = NOTHING_SPECIAL_STATE; } /** * Writes a character to the output. Note that a call to this method * may result in multiple writes to the underling Writer in order to * convert naked linefeeds to NETASCII line separators and to double * line-leading periods. This is transparent to the programmer and * is only mentioned for completeness. * * @param ch The character to write. * @throws IOException If an error occurs while writing to the * underlying output. */ @Override public void write(final int ch) throws IOException { synchronized (lock) { switch (ch) { case '\r': state = LAST_WAS_CR_STATE; output.write('\r'); return ; case '\n': if (state != LAST_WAS_CR_STATE) { output.write('\r'); } output.write('\n'); state = LAST_WAS_NL_STATE; return ; case '.': // Double the dot at the beginning of a line if (state == LAST_WAS_NL_STATE) { output.write('.'); } //$FALL-THROUGH$ default: state = NOTHING_SPECIAL_STATE; output.write(ch); } } } /** * Writes a number of characters from a character array to the output * starting from a given offset. * * @param buffer The character array to write. * @param offset The offset into the array at which to start copying data. * @param length The number of characters to write. * @throws IOException If an error occurs while writing to the underlying * output. */ @Override public void write(final char[] buffer, int offset, int length) throws IOException { synchronized (lock) { while (length-- > 0) { write(buffer[offset++]); } } } /** * Writes a character array to the output. * * @param buffer The character array to write. * @throws IOException If an error occurs while writing to the underlying * output. */ @Override public void write(final char[] buffer) throws IOException { write(buffer, 0, buffer.length); } /** * Writes a String to the output. * * @param string The String to write. * @throws IOException If an error occurs while writing to the underlying * output. */ @Override public void write(final String string) throws IOException { write(string.toCharArray()); } /** * Writes part of a String to the output starting from a given offset. * * @param string The String to write. * @param offset The offset into the String at which to start copying data. * @param length The number of characters to write. * @throws IOException If an error occurs while writing to the underlying * output. */ @Override public void write(final String string, final int offset, final int length) throws IOException { write(string.toCharArray(), offset, length); } /** * Flushes the underlying output, writing all buffered output. * * @throws IOException If an error occurs while writing to the underlying * output. */ @Override public void flush() throws IOException { synchronized (lock) { output.flush(); } } /** * Flushes the underlying output, writing all buffered output, but doesn't * actually close the underlying stream. The underlying stream may still * be used for communicating with the server and therefore is not closed. * * @throws IOException If an error occurs while writing to the underlying * output or closing the Writer. */ @Override public void close() throws IOException { synchronized (lock) { if (output == null) { return ; } if (state == LAST_WAS_CR_STATE) { output.write('\n'); } else if (state != LAST_WAS_NL_STATE) { output.write("\r\n"); } output.write(".\r\n"); output.flush(); output = null; } } }
⏎ org/apache/commons/net/io/DotTerminatedMessageWriter.java
Or download all of them as a single archive file:
File name: commons-net-3.8.0-sources.jar File size: 437325 bytes Release date: 2020-01-22 Download
⇒ Download and Install commons-net.jar Binary Package
2009-02-08, 133228👍, 0💬
Popular Posts:
A stream buffer is a stream-based representation of an XML infoset in Java. Stream buffers are desig...
What Is poi-3.5.jar - Part 2? poi-3.5.jar is one of the JAR files for Apache POI 3.5, which provides...
JDK 11 jdk.rmic.jmod is the JMOD file for JDK 11 RMI (Remote Method Invocation) Compiler Tool tool, ...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
SLF4J API is a simple API that allows to plug in any desired logging library at deployment time. Her...