java.io.Closeable#close ( )源码实例Demo

下面列出了java.io.Closeable#close ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void testGetConnectionHandleNoArgPrefersEmptySourceTarget() throws IOException {
  HBaseConnectionHandle connectionHandle = hBaseConnectionPool.getConnectionHandle();
  HBaseConnectionWrapper connection = connectionHandle.getConnection();
  List<Closeable> toClose = new ArrayList<>();
  toClose.add( connectionHandle );
  for ( int i = 0; i < 100; i++ ) {
    toClose.add( hBaseConnectionPool.getConnectionHandle( "source" ) );
  }
  for ( int i = 0; i < 100; i++ ) {
    toClose.add( hBaseConnectionPool.getConnectionHandle( "target", mock( Properties.class ) ) );
  }
  for ( Closeable closeable : toClose ) {
    closeable.close();
  }
  assertEquals( connection, hBaseConnectionPool.getConnectionHandle().getConnection() );
}
 
源代码2 项目: giffun   文件: BitmapUtils.java
/**
 * Close the given closeable object (Stream) in a safe way: check if it is null and catch-log
 * exception thrown.
 *
 * @param closeable the closable object to close
 */
private static void closeSafe(Closeable closeable) {
  if (closeable != null) {
    try {
      closeable.close();
    } catch (IOException ignored) {
    }
  }
}
 
源代码3 项目: WelikeAndroid   文件: DiskLruCache.java
/**
 * Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null.
 */
public static void closeQuietly(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (RuntimeException rethrown) {
            throw rethrown;
        } catch (Exception ignored) {
        }
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: GestureUtils.java
/**
 * Closes the specified stream.
 *
 * @param stream The stream to close.
 */
static void closeStream(Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            Log.e(LOG_TAG, "Could not close stream", e);
        }
    }
}
 
源代码5 项目: dependency-track   文件: NistMirrorTask.java
/**
 * Closes a closable object.
 * @param object the object to close
 */
private void close(final Closeable object) {
    if (object != null) {
        try {
            object.close();
        } catch (IOException e) {
            LOGGER.warn("Error closing stream", e);
        }
    }
}
 
源代码6 项目: phoenix   文件: DirectHTableWriter.java
private void tryClosingResourceSilently(Closeable res) {
    if (res != null) {
        try {
            res.close();
        } catch (IOException e) {
            LOGGER.error("Closing resource: " + res + " failed with error: ", e);
        }
    }
}
 
源代码7 项目: cxf   文件: ServerImpl.java
public void stop() {
    if (stopped) {
        return;
    }

    LOG.fine("Server is stopping.");

    for (Closeable c : endpoint.getCleanupHooks()) {
        try {
            c.close();
        } catch (IOException e) {
            //ignore
        }
    }
    if (slcMgr != null) {
        slcMgr.stopServer(this);
    }

    MessageObserver mo = getDestination().getMessageObserver();
    if (mo instanceof MultipleEndpointObserver) {
        ((MultipleEndpointObserver)mo).getEndpoints().remove(endpoint);
        if (((MultipleEndpointObserver)mo).getEndpoints().isEmpty()) {
            getDestination().setMessageObserver(null);
        }
    } else {
        getDestination().setMessageObserver(null);
    }
    stopped = true;
}
 
源代码8 项目: AndroidUtilCode   文件: CloseUtils.java
/**
 * Close the io stream quietly.
 *
 * @param closeables The closeables.
 */
public static void closeIOQuietly(final Closeable... closeables) {
    if (closeables == null) return;
    for (Closeable closeable : closeables) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException ignored) {
            }
        }
    }
}
 
源代码9 项目: iBeebo   文件: Utility.java
public static void closeSilently(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException ignored) {

        }
    }
}
 
源代码10 项目: BreakPointUploadUtil   文件: UploadFileUtil.java
public static void close(Closeable stream) {
    try {
        if (stream != null)
            stream.close();
    } catch (IOException e) {
    }
}
 
源代码11 项目: fabric8-forge   文件: IOHelper.java
/**
 * Closes the given resource if it is available, logging any closing exceptions to the given log.
 *
 * @param closeable the object to close
 */
public static void close(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException e) {
            // ignore
        }
    }
}
 
源代码12 项目: mvn-golang   文件: IOUtils.java
/**
 * Close a closeable object quietly, added because such method in APACHE-IO
 * has been deprecated
 *
 * @param closeable object to be closed
 */
public static void closeSilently(@Nullable final Closeable closeable) {
  try {
    if (closeable != null) {
      closeable.close();
    }
  } catch (final IOException ignoring) {
  }
}
 
源代码13 项目: XERUNG   文件: CropUtil.java
public static void closeSilently(@Nullable Closeable c) {
    if (c == null) return;
    try {
        c.close();
    } catch (Throwable t) {
        // Do nothing
    }
}
 
源代码14 项目: Serial   文件: InternalSerialUtils.java
/**
 * Closes the passed closeable without raising exceptions.
 *
 * @param closeable the object to close or null
 */
public static void closeSilently(@Nullable Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException ignore) {
        }
    }
}
 
源代码15 项目: FastAndroid   文件: BitmapUtils.java
/**
 * 关闭 IO
 *
 * @param closeables closeables
 */
public static void closeIO(Closeable... closeables) {
    if (closeables == null) return;
    for (Closeable closeable : closeables) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
源代码16 项目: pinpoint   文件: IOUtils.java
public static void closeQuietly(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException ignore) {
            // skip
        }
    }
}
 
源代码17 项目: sonar-checkstyle   文件: CheckstyleExecutor.java
@VisibleForTesting
static void close(Closeable closeable) {
    try {
        closeable.close();
    }
    catch (IOException ex) {
        throw new IllegalStateException("failed to close object", ex);
    }
}
 
源代码18 项目: open-ig   文件: CommonResources.java
/**
 * Close the given closeable silently.
 * @param c the closeable
 */
void close0(Closeable c) {
	try {
		if (c != null) {
			c.close();
		}
	} catch (IOException ex) {
		// Ignored
	}
}
 
源代码19 项目: neoscada   文件: CommandExecutor.java
protected static void closeStream ( final Closeable stream )
{
    if ( stream == null )
    {
        return;
    }
    try
    {
        stream.close ();
    }
    catch ( final IOException e )
    {
        logger.warn ( "Failed to close stream", e );
    }
}
 
源代码20 项目: protoc-jar   文件: PlatformDetector.java
private static void closeQuietly(Closeable obj) {
    try {
        if (obj != null) {
            obj.close();
        }
    } catch (IOException ignored) {
        // Ignore.
    }
}
 
 方法所在类
 同类方法