本文整理了Java中org.infinispan.commons.util.Util.close()
方法的一些代码示例,展示了Util.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.close()
方法的具体详情如下:
包路径:org.infinispan.commons.util.Util
类名称:Util
方法名:close
暂无
代码示例来源:origin: org.infinispan/infinispan-commons
public static void close(AutoCloseable... cls) {
for (AutoCloseable cl : cls) {
close(cl);
}
}
代码示例来源:origin: org.infinispan/infinispan-commons
private static void loadKeyStore(KeyStore ks, String keyStoreFileName, char[] keyStorePassword, ClassLoader classLoader) throws IOException, GeneralSecurityException {
InputStream is = null;
try {
if (keyStoreFileName.startsWith(CLASSPATH_RESOURCE)) {
String fileName = keyStoreFileName.substring(keyStoreFileName.indexOf(":") + 1);
is = Util.getResourceAsStream(fileName, classLoader);
if (is == null) {
throw log.cannotFindResource(keyStoreFileName);
}
} else {
is = new BufferedInputStream(new FileInputStream(keyStoreFileName));
}
ks.load(is, keyStorePassword);
} finally {
Util.close(is);
}
}
}
代码示例来源:origin: org.infinispan/infinispan-commons
/**
* Convenience method for decoding data to a file.
*
* @param dataToDecode Base64-encoded data as a string
* @param filename Filename for saving decoded data
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*
* @since 2.1
*/
public static boolean decodeToFile(String dataToDecode, String filename) {
boolean success = false;
Base64.OutputStream bos = null;
try {
bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.DECODE);
bos.write(dataToDecode.getBytes(PREFERRED_ENCODING));
success = true;
} // end try
catch (java.io.IOException e) {
success = false;
} // end catch: IOException
finally {
Util.close(bos);
} // end finally
return success;
} // end decodeToFile
代码示例来源:origin: org.infinispan/infinispan-commons
Util.close(bais);
Util.close(ois);
代码示例来源:origin: org.infinispan/infinispan-commons
Util.close(bis);
代码示例来源:origin: org.infinispan/infinispan-commons
Util.close(bis);
代码示例来源:origin: org.infinispan/infinispan-commons
/**
* Convenience method for encoding data to a file.
*
* @param dataToEncode byte array of data to encode in base64 form
* @param filename Filename for saving encoded data
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*
* @since 2.1
*/
public static boolean encodeToFile(byte[] dataToEncode, String filename) {
boolean success = false;
Base64.OutputStream bos = null;
try {
bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.ENCODE);
bos.write(dataToEncode);
success = true;
} // end try
catch (java.io.IOException e) {
success = false;
} // end catch: IOException
finally {
Util.close(bos);
} // end finally
return success;
} // end encodeToFile
代码示例来源:origin: org.infinispan/infinispan-commons
Util.close(oos, gzos, b64os, baos);
代码示例来源:origin: org.infinispan/infinispan-embedded-query
private ConfigurationBuilderHolder parseFile(ClassLoaderService classLoaderService, String filename, String transportOverrideResource) {
InputStream is = classLoaderService.locateResourceStream(filename);
try {
//Infinispan requires the context ClassLoader to have full visibility on all
//its components and eventual extension points even *during* configuration parsing.
final Thread currentThread = Thread.currentThread();
final ClassLoader originalContextClassLoader = currentThread.getContextClassLoader();
try {
currentThread.setContextClassLoader(ispnClassLoadr);
ConfigurationBuilderHolder builderHolder = configurationParser.parse(is);
//Workaround Infinispan's ClassLoader strategies to bend to our will:
fixClassLoaders(builderHolder);
patchTransportConfiguration(builderHolder, transportOverrideResource);
return builderHolder;
} finally {
currentThread.setContextClassLoader(originalContextClassLoader);
}
} finally {
Util.close(is);
}
}
代码示例来源:origin: org.infinispan/infinispan-cli-client
private void testManPage(String name) throws Exception {
InputStream is = null;
try {
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
Man2Ansi man2ansi = new Man2Ansi(72);
man2ansi.render(is);
} finally {
Util.close(is);
}
}
}
代码示例来源:origin: org.infinispan/infinispan-cli-client
public void testStandardInput() throws Exception {
ByteArrayInputStream bais = null;
ByteArrayOutputStream baos = null;
InputStream in = System.in;
PrintStream out = System.out;
try {
bais = new ByteArrayInputStream("version;\n".getBytes(UTF_8));
baos = new ByteArrayOutputStream();
System.setIn(bais);
System.setOut(new PrintStream(baos));
Shell shell = new ShellImpl();
shell.init(new String[]{"-f","-"});
shell.run();
System.out.flush();
String output = baos.toString("UTF-8");
assert output.contains("Version");
} finally {
System.setIn(in);
System.setOut(out);
Util.close(bais, baos);
}
}
}
代码示例来源:origin: org.infinispan/infinispan-gui-demo
cacheManager = new DefaultCacheManager(stream);
} finally {
Util.close(stream);
log.warn("Unable to open config file [" + cacheConfigFile + "] for display", e);
} finally {
Util.close(is);
内容来源于网络,如有侵权,请联系作者删除!