本文整理汇总了C#中biz.ritter.javapi.close方法的典型用法代码示例。如果您正苦于以下问题:C# biz.ritter.javapi.close方法的具体用法?C# biz.ritter.javapi.close怎么用?C# biz.ritter.javapi.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biz.ritter.javapi
的用法示例。
在下文中一共展示了biz.ritter.javapi.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: closeQuietly
private static void closeQuietly(java.io.InputStream inJ)
{
if (inJ == null) {
return;
}
try {
inJ.close ();
} catch (java.io.IOException e) {
}
}
示例2: readFullyAndClose
/**
* Reads all the bytes from the given input stream.
*
* Calls read multiple times on the given input stream until it receives an
* end of file marker. Returns the combined results as a byte array. Note
* that this method may block if the underlying stream read blocks.
*
* @param is
* the input stream to be read.
* @return the content of the stream as a byte array.
* @throws IOException
* if a read error occurs.
*/
public static byte[] readFullyAndClose(java.io.InputStream isJ)
{
// throws IOException {
try {
// Initial read
byte[] buffer = new byte[1024];
int count = isJ.read(buffer);
int nextByte = isJ.read();
// Did we get it all in one read?
if (nextByte == -1) {
byte[] dest = new byte[count];
java.lang.SystemJ.arraycopy(buffer, 0, dest, 0, count);
return dest;
}
// Requires additional reads
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(count * 2);
baos.write(buffer, 0, count);
baos.write(nextByte);
while (true) {
count = isJ.read(buffer);
if (count == -1) {
return baos.toByteArray();
}
baos.write(buffer, 0, count);
}
} finally {
isJ.close();
}
}