回退流

public static void main(String[] args) throws Exception {

		String str = "www.baidu.com";
		PushbackInputStream push = null;
		ByteArrayInputStream bai = null;
		bai = new ByteArrayInputStream(str.getBytes());
		push = new PushbackInputStream(bai);
		int temp;
		while((temp=push.read())!=-1){
			if(temp=='.'){
				push.unread(temp);
				temp=push.read();
				System.out.println("(退回"+(char)temp+")");
			}else{
				System.out.println((char)temp);
			}
		}
	}

你可能感兴趣的:(回退流)