org.apache.commons.net.io.Util.closeQuietly()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中org.apache.commons.net.io.Util.closeQuietly()方法的一些代码示例,展示了Util.closeQuietly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.closeQuietly()方法的具体详情如下:
包路径:org.apache.commons.net.io.Util
类名称:Util
方法名:closeQuietly

Util.closeQuietly介绍

[英]Closes the object quietly, catching rather than throwing IOException. Intended for use from finally blocks.
[中]安静地关闭对象,捕捉而不是抛出异常。用于最后一个区块。

代码示例

代码示例来源: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

@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

/**
 *
 * @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: 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: commons-net/commons-net

false);
} finally {
  Util.closeQuietly(input);
  Util.closeQuietly(socket);
  if (csl != null) {

代码示例来源:origin: commons-net/commons-net

Util.closeQuietly(socket);

代码示例来源:origin: commons-net/commons-net

Util.closeQuietly(socket); // ignore close errors here
if (csl != 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;
}

代码示例来源:origin: org.jetbrains.intellij.deps/commons-vfs2

/**
 * Initiate list parsing for MLSD listings.
 *
 * @param pathname
 * @return the engine
 * @throws IOException
 */
private FTPListParseEngine initiateMListParsing(String pathname) throws IOException {
  Socket socket;
  FTPListParseEngine engine = new FTPListParseEngine(new MLSxLoggingEntryParser(log));
  if ((socket = _openDataConnection_(FTPCommand.MLSD, pathname)) == null) {
    return engine;
  }
  try {
    engine.readServerList(socket.getInputStream(), getControlEncoding());
  } finally {
    Util.closeQuietly(socket);
    completePendingCommand();
  }
  return engine;
}
//[IntelliJ] WI-12266 Support directory listing with MLSD command (adding logging of mlsd command)-------

代码示例来源:origin: org.jetbrains.intellij.deps/commons-vfs2

/**
 * Initiate list parsing for MLSD listings.
 *
 * @param pathname
 * @return the engine
 * @throws IOException
 */
public FTPListParseEngine initiateMListParsing(String pathname) throws IOException {
  Socket socket;
  FTPListParseEngine engine = new FTPListParseEngine(new MLSxLoggingEntryParser(log));
  if ((socket = _openDataConnection_(FTPCommand.MLSD, pathname)) == null) {
    return engine;
  }
  try {
    engine.readServerList(socket.getInputStream(), getControlEncoding());
  } finally {
    Util.closeQuietly(socket);
    completePendingCommand();
  }
  return engine;
}
//[IntelliJ] WI-12266 Support directory listing with MLSD command (adding logging of mlsd command)-------

相关文章