⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 definitelengthinputstream.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   DefiniteLengthInputStream.java

package org.bouncycastle.asn1;

import java.io.*;

// Referenced classes of package org.bouncycastle.asn1:
//			LimitedInputStream

class DefiniteLengthInputStream extends LimitedInputStream
{

	private int _length;

	DefiniteLengthInputStream(InputStream in, int length)
	{
		super(in);
		if (length < 0)
		{
			throw new IllegalArgumentException("negative lengths not allowed");
		} else
		{
			_length = length;
			return;
		}
	}

	public int read()
		throws IOException
	{
		if (_length > 0)
		{
			int b = _in.read();
			if (b < 0)
			{
				throw new EOFException();
			} else
			{
				_length--;
				return b;
			}
		} else
		{
			setParentEofDetect(true);
			return -1;
		}
	}

	public int read(byte buf[], int off, int len)
		throws IOException
	{
		if (_length > 0)
		{
			int toRead = Math.min(len, _length);
			int numRead = _in.read(buf, off, toRead);
			if (numRead < 0)
			{
				throw new EOFException();
			} else
			{
				_length -= numRead;
				return numRead;
			}
		} else
		{
			setParentEofDetect(true);
			return -1;
		}
	}

	byte[] toByteArray()
		throws IOException
	{
		byte bytes[] = new byte[_length];
		if (_length > 0)
		{
			int pos = 0;
			do
			{
				int read = _in.read(bytes, pos, _length - pos);
				if (read < 0)
					throw new EOFException();
				pos += read;
			} while (pos < _length);
			_length = 0;
		}
		setParentEofDetect(true);
		return bytes;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -