0 0

流的mark方法的形参int readlimit什么意思5

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * 作者:阳光的味道
 * 功能: InputStream示例
 * 日期:2010/11/10
 * */
public class InputStreamDemo3 {
	public static void main(String args[]) throws IOException{
		String str = "12345678901234567890";
		byte[] ch = str.getBytes();
		InputStream in = new ByteArrayInputStream(ch);
		if(in.markSupported()){
			System.out.println("所使用的流支持mark和reset");
		}
		in.mark(1);
		//搞不懂这里的readlimit是什么意思,我随便怎么修改都输出同样的结果
		int count = 0 ;
		for(int i = 0 ; i < str.length(); i ++){
			count ++;
			int read = in.read();
			if(count%5 == 0){
				in.reset();
			}
			System.out.print((char)read);
		}
		in.close();
	}
}
/*out:
所使用的流支持mark和reset
12345123451234512345*/

 

请问大家readlImit是什么意思呢?

OO 
2010年11月10日 15:01

1个答案 按时间排序 按投票排序

0 0

以后这种问题最好看看API

readlimit的意思是说

当 mark 或者 rest 后的从stream里面读出的bytes数量超过了mark的limit时候,mark就失效了

2010年11月20日 20:59

相关推荐

Global site tag (gtag.js) - Google Analytics