PushBackInputStream 回退流操作用法
发布日期:2021-06-30 21:07:51 浏览次数:2 分类:技术文章

本文共 480 字,大约阅读时间需要 1 分钟。

String fileName = "Hellow,How Are You!";		PushbackInputStream push = null;		ByteArrayInputStream bat = null;		bat = new ByteArrayInputStream(fileName.getBytes());		push = new PushbackInputStream(bat); //回退流		int temp = 0;		while ((temp = push.read()) != -1) {			if (temp == ',') {  //遇到逗号,在逗号前加(,boy)				push.unread(temp);				temp = push.read();				System.out.print(",boy" + (char)temp );			} else {				System.out.print( (char)temp); //正常打印流内容			}		}

打印如下:   Hellow,boy,How Are You!

转载地址:https://liuyan.blog.csdn.net/article/details/81172404 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:向文件末尾追加数据内容而不是覆盖
下一篇:ArrayList 与 Vector 的分析

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月19日 02时29分36秒