本文整理了Java中org.apache.commons.net.io.Util
类的一些代码示例,展示了Util
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util
类的具体详情如下:
包路径:org.apache.commons.net.io.Util
类名称:Util
[英]The Util class cannot be instantiated and stores short static convenience methods that are often quite useful.
[中]Util类不能被实例化,它存储了通常非常有用的简短静态便利方法。
代码示例来源:origin: commons-net/commons-net
/***
* Same as <code> copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE); </code>
* @param source where to copy from
* @param dest where to copy to
* @return number of bytes copied
* @throws CopyStreamException on error
***/
public static final long copyStream(InputStream source, OutputStream dest)
throws CopyStreamException
{
return copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE);
}
代码示例来源:origin: commons-net/commons-net
private static KeyStore loadStore(String storeType, File storePath, String storePass)
throws KeyStoreException, IOException, GeneralSecurityException {
KeyStore ks = KeyStore.getInstance(storeType);
FileInputStream stream = null;
try {
stream = new FileInputStream(storePath);
ks.load(stream, storePass.toCharArray());
} finally {
Util.closeQuietly(stream);
}
return ks;
}
代码示例来源:origin: commons-net/commons-net
/***
* Same as <code> copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE); </code>
* @param source where to copy from
* @param dest where to copy to
* @return number of bytes copied
* @throws CopyStreamException on error
***/
public static final long copyReader(Reader source, Writer dest)
throws CopyStreamException
{
return copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
}
代码示例来源:origin: commons-net/commons-net
Util.copyStream(input, local, getBufferSize(),
CopyStreamEvent.UNKNOWN_STREAM_SIZE, __mergeListeners(csl),
false);
} finally {
Util.closeQuietly(input);
Util.closeQuietly(socket);
if (csl != null) {
代码示例来源:origin: commons-net/commons-net
Util.copyStream(local, output, getBufferSize(),
CopyStreamEvent.UNKNOWN_STREAM_SIZE, __mergeListeners(csl),
false);
Util.closeQuietly(socket); // ignore close errors here
if (csl != null) {
代码示例来源:origin: commons-net/commons-net
/***
* Copies the contents of an InputStream to an OutputStream using a
* copy buffer of a given size. The contents of the InputStream are
* read until the end of the stream is reached, but neither the
* source nor the destination are closed. You must do this yourself
* outside of the method call. The number of bytes read/written is
* returned.
*
* @param source The source InputStream.
* @param dest The destination OutputStream.
* @param bufferSize The number of bytes to buffer during the copy.
* A zero or negative value means to use {@link #DEFAULT_COPY_BUFFER_SIZE}.
* @return The number of bytes read/written in the copy operation.
* @throws CopyStreamException If an error occurs while reading from the
* source or writing to the destination. The CopyStreamException
* will contain the number of bytes confirmed to have been
* transferred before an
* IOException occurred, and it will also contain the IOException
* that caused the error. These values can be retrieved with
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
public static final long copyStream(InputStream source, OutputStream dest,
int bufferSize)
throws CopyStreamException
{
return copyStream(source, dest, bufferSize,
CopyStreamEvent.UNKNOWN_STREAM_SIZE, null);
}
代码示例来源:origin: commons-net/commons-net
/***
* Copies the contents of a Reader to a Writer using a
* copy buffer of a given size. The contents of the Reader are
* read until its end is reached, but neither the source nor the
* destination are closed. You must do this yourself outside of the
* method call. The number of characters read/written is returned.
*
* @param source The source Reader.
* @param dest The destination writer.
* @param bufferSize The number of characters to buffer during the copy.
* A zero or negative value means to use {@link #DEFAULT_COPY_BUFFER_SIZE}.
* @return The number of characters read/written in the copy operation.
* @throws CopyStreamException If an error occurs while reading from the
* source or writing to the destination. The CopyStreamException
* will contain the number of bytes confirmed to have been
* transferred before an
* IOException occurred, and it will also contain the IOException
* that caused the error. These values can be retrieved with
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
public static final long copyReader(Reader source, Writer dest,
int bufferSize)
throws CopyStreamException
{
return copyReader(source, dest, bufferSize,
CopyStreamEvent.UNKNOWN_STREAM_SIZE, null);
}
代码示例来源:origin: commons-net/commons-net
@Override
public String next() throws NoSuchElementException {
if (savedException != null){
throw new NoSuchElementException(savedException.toString());
}
String prev = line;
if (prev == null) {
throw new NoSuchElementException();
}
try {
line = reader.readLine(); // save next line
if (line == null) {
Util.closeQuietly(reader);
}
} catch (IOException ex) {
savedException = ex; // if it fails, save the exception, as it does not apply to this call
Util.closeQuietly(reader);
}
return prev;
}
代码示例来源:origin: commons-net/commons-net
throws CopyStreamException
return copyStream(source, dest, bufferSize, streamSize, listener,
true);
代码示例来源:origin: commons-net/commons-net
/***
* List the command help from the server.
* <p>
* @return The sever help information.
* @throws 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.
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
***/
public String listHelp() throws IOException
{
if (!NNTPReply.isInformational(help())) {
return null;
}
StringWriter help = new StringWriter();
BufferedReader reader = new DotTerminatedMessageReader(_reader_);
Util.copyReader(reader, help);
reader.close();
help.close();
return help.toString();
}
代码示例来源:origin: commons-net/commons-net
/**
*
* @param _reader the reader to wrap
* @param addDotReader whether to additionally wrap the reader in a DotTerminatedMessageReader
* @throws IOException
*/
ReplyIterator(BufferedReader _reader, boolean addDotReader) throws IOException {
reader = addDotReader ? new DotTerminatedMessageReader(_reader) : _reader;
line = reader.readLine(); // prime the iterator
if (line == null) {
Util.closeQuietly(reader);
}
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.net
/***
* Same as <code> copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE); </code>
***/
public static final long copyStream(InputStream source, OutputStream dest)
throws CopyStreamException
{
return copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE);
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.net
/***
* Same as <code> copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE); </code>
***/
public static final long copyReader(Reader source, Writer dest)
throws CopyStreamException
{
return copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
}
代码示例来源:origin: commons-net/commons-net
/**
* Initiate list parsing for MLSD listings.
*
* @param pathname
* @return the engine
* @throws IOException
*/
private FTPListParseEngine initiateMListParsing(String pathname) throws IOException
{
Socket socket = _openDataConnection_(FTPCmd.MLSD, pathname);
FTPListParseEngine engine = new FTPListParseEngine(MLSxEntryParser.getInstance(), __configuration);
if (socket == null)
{
return engine;
}
try {
engine.readServerList(socket.getInputStream(), getControlEncoding());
}
finally {
Util.closeQuietly(socket);
completePendingCommand();
}
return engine;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-net
/***
* Same as <code> copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE); </code>
***/
public static final long copyStream(InputStream source, OutputStream dest)
throws CopyStreamException
{
return copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-net
/***
* Same as <code> copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE); </code>
***/
public static final long copyReader(Reader source, Writer dest)
throws CopyStreamException
{
return copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
}
代码示例来源:origin: commons-net/commons-net
Util.closeQuietly(socket);
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.net
/***
* Copies the contents of an InputStream to an OutputStream using a
* copy buffer of a given size. The contents of the InputStream are
* read until the end of the stream is reached, but neither the
* source nor the destination are closed. You must do this yourself
* outside of the method call. The number of bytes read/written is
* returned.
* <p>
* @param source The source InputStream.
* @param dest The destination OutputStream.
* @return The number of bytes read/written in the copy operation.
* @exception CopyStreamException If an error occurs while reading from the
* source or writing to the destination. The CopyStreamException
* will contain the number of bytes confirmed to have been
* transferred before an
* IOException occurred, and it will also contain the IOException
* that caused the error. These values can be retrieved with
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
public static final long copyStream(InputStream source, OutputStream dest,
int bufferSize)
throws CopyStreamException
{
return copyStream(source, dest, bufferSize,
CopyStreamEvent.UNKNOWN_STREAM_SIZE, null);
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.net
/***
* Copies the contents of a Reader to a Writer using a
* copy buffer of a given size. The contents of the Reader are
* read until its end is reached, but neither the source nor the
* destination are closed. You must do this yourself outside of the
* method call. The number of characters read/written is returned.
* <p>
* @param source The source Reader.
* @param dest The destination writer.
* @param bufferSize The number of characters to buffer during the copy.
* @return The number of characters read/written in the copy operation.
* @exception CopyStreamException If an error occurs while reading from the
* source or writing to the destination. The CopyStreamException
* will contain the number of bytes confirmed to have been
* transferred before an
* IOException occurred, and it will also contain the IOException
* that caused the error. These values can be retrieved with
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
public static final long copyReader(Reader source, Writer dest,
int bufferSize)
throws CopyStreamException
{
return copyReader(source, dest, bufferSize,
CopyStreamEvent.UNKNOWN_STREAM_SIZE, null);
}
代码示例来源:origin: org.ikasan/ikasan-ftp-endpoint
private KeyStore loadStore(String storeType, File storePath, String storePass)
throws KeyStoreException, IOException, GeneralSecurityException {
KeyStore ks = KeyStore.getInstance(storeType);
FileInputStream stream = null;
try {
stream = new FileInputStream(storePath);
ks.load(stream, storePass.toCharArray());
} finally {
Util.closeQuietly(stream);
}
return ks;
}
内容来源于网络,如有侵权,请联系作者删除!