zoukankan      html  css  js  c++  java
  • java 回退流

     1 import java.io.ByteArrayInputStream;
    2 import java.io.IOException;
    3 import java.io.PushbackInputStream;
    4
    5
    6 public class PushInputStreamDemo {
    7 public static void main(String[] args) throws Exception {
    8 String str="www.hjw.com";
    9 ByteArrayInputStream bai=new ByteArrayInputStream(str.getBytes());
    10 PushbackInputStream push=new PushbackInputStream(bai);
    11 System.out.println("读取后的数据为:");
    12 int temp=0;
    13 while((temp=push.read())!=-1){
    14 if(temp=='.'){
    15 push.unread(temp);
    16 temp=push.read();
    17 System.out.print("(退回"+(char)temp+")");//为了显示内容,打印出来
    18 }else{
    19 System.out.print((char)temp);
    20 }
    21 }
    22 }
    23 }
  • 相关阅读:
    repr() Vs str()
    默认参数
    元组
    字典
    电脑可以办的两类最基本的事情
    代码块
    变量名
    print的逻辑
    input的逻辑
    让python2听懂中文
  • 原文地址:https://www.cnblogs.com/dennisac/p/2418413.html
Copyright © 2011-2022 走看看