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

📄 sequenceinputstream.java

📁 kaffe是一个java虚拟机的源代码。里面包含了一些java例程和标准的java包。
💻 JAVA
字号:
package java.io;import java.util.Enumeration;import java.util.Vector;/* * Java core library component. * * Copyright (c) 1997, 1998 *      Transvirtual Technologies, Inc.  All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */public class SequenceInputStream  extends InputStream{	private Vector streams = new Vector();	private int currentStreamIdx;	private InputStream currentStream;public SequenceInputStream(Enumeration e) {	while (e.hasMoreElements()) {		streams.addElement(e.nextElement());	}	currentStream = (InputStream)streams.elementAt(0);}public SequenceInputStream(InputStream s1, InputStream s2) {	streams.addElement(s1);	streams.addElement(s2);	currentStream = s1;}public int available() throws IOException {	if (currentStreamIdx >= streams.size()) {		return (0);	}	else {		return (currentStream.available());	}}public void close() throws IOException {	for (int stream = currentStreamIdx; stream < streams.size(); stream++) {		((InputStream)streams.elementAt(stream)).close();	}	currentStreamIdx = 0;	currentStream = null;	streams = new Vector();}public int read() throws IOException {	if (currentStreamIdx >= streams.size()) {		return -1;	}	for (;;) {		final int data = currentStream.read();		if (data != -1) {			return (data);		}		currentStream.close();		currentStreamIdx++;		if (currentStreamIdx >= streams.size()) {			return -1;		}		currentStream = (InputStream)streams.elementAt(currentStreamIdx);	}}public int read(byte buf[], int pos, int len) throws IOException {	if (currentStreamIdx >= streams.size()) {		return -1;	}	for (;;) {		final int nr = currentStream.read(buf, pos, len);		if (nr != -1) {			return (nr);		}		currentStream.close();		currentStreamIdx++;		if (currentStreamIdx >= streams.size()) {			return -1;		}		currentStream = (InputStream)streams.elementAt(currentStreamIdx);	}}}

⌨️ 快捷键说明

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