本文整理汇总了C#中biz.ritter.javapi.read方法的典型用法代码示例。如果您正苦于以下问题:C# biz.ritter.javapi.read方法的具体用法?C# biz.ritter.javapi.read怎么用?C# biz.ritter.javapi.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biz.ritter.javapi
的用法示例。
在下文中一共展示了biz.ritter.javapi.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: readShortLE
//throws IOException
/*
* Read a two-byte short in little-endian order.
*/
internal int readShortLE(java.io.InputStream inJ)
{
if (inJ.read(b, 0, 2) == 2) {
return (b[0] & 0XFF) | ((b[1] & 0XFF) << 8);
} else {
throw new java.io.EOFException();//Messages.getString("archive.3C"));
}
}
示例3: readIntLE
//throws IOException
/*
* Read a four-byte int in little-endian order.
*/
internal long readIntLE(java.io.InputStream inJ)
{
if (inJ.read(b, 0, 4) == 4) {
return ( ((b[0] & 0XFF))
| ((b[1] & 0XFF) << 8)
| ((b[2] & 0XFF) << 16)
| ((b[3] & 0XFF) << 24))
& 0XFFFFFFFFL; // Here for sure NO sign extension is wanted.
} else {
throw new java.io.EOFException();//Messages.getString("archive.3D"));
}
}
示例4: myReadFully
//throws IOException
private void myReadFully(java.io.InputStream inJ, byte[] b)
{
int len = b.Length;
int off = 0;
while (len > 0) {
int count = inJ.read(b, off, len);
if (count <= 0) {
throw new java.io.EOFException();
}
off += count;
len -= count;
}
}
示例5: readFully
/*
* Helper to read the entire contents of the manifest from the
* given input stream. Usually we can do this in a single read
* but we need to account for 'infinite' streams, by ensuring we
* have a line feed within a reasonable number of characters.
*/
private byte[] readFully(java.io.InputStream isJ)
{
// throws IOException {
// Initial read
byte[] buffer = new byte[4096];
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;
}
// Does it look like a manifest?
if (!containsLine(buffer, count)) {
// archive.2E=Manifest is too long
throw new java.io.IOException("Manifest is too long"); //$NON-NLS-1$
}
// 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);
}
}