zoukankan      html  css  js  c++  java
  • InputStream 控制台输出方法

    public class IOTest{

      public static void main(String[] args){

        File file=new File("");

        inputStream01(file);

      }

      //单个输出英文字符

      public static void inputStream01(File file){

        InputStream input=new FileInputStream(file);

        int tem;

        while((tem=input.read())!=-1){

          System.out.print((char)tem);  

        }

        input.close();

      }

      //以字节形式输出,当为中文时会自动拼接成为中文(当读到半个中文时输出乱码,对考贝文件无影响)

      public static void inputStream02(File file){

        InputStream input=new FileInputStream(file);

        byte[] by=new byte[len];

        int tem;

        while((tem=input.read(by))!=-1){

          System.out.print(new String(by,0,tem));  

        }

        input.close();

      }

      //单个英文或中文作为一个字符输出

    public static void inputStream03(File file){

        InputStream input=new FileInputStream(file);

        byte tem;

        while((tem=input.read())!=-1){

          //当tem为负数时输出内容为中文自动和下一个ibput.read()拼接成为中文字符

          //当tem正数时为英文

          if(tem<0){

            byte tem01=input.read();

            byte[] by={tem,tem01};

            System.out.print(new String(by,0,by.length));

          }else{

            System.out.print((char)tem);

          }

        }

        input.close();

      }

    }

  • 相关阅读:
    All about Python
    All about TestComplete
    All about Ranorex
    围观大神们的博客
    CRP实施方法论(转)
    启发式测试策略模型(Heuristic Test Strategy Model,简称HTSM)(转)
    soapUI学习笔记---断言的小使用(转)
    soapUI学习笔记--用例字段参数化(转)
    常用功能测试点汇总(转)
    记一次性能测试实践1
  • 原文地址:https://www.cnblogs.com/li19941999/p/10358963.html
Copyright © 2011-2022 走看看