zoukankan      html  css  js  c++  java
  • InputStream中read方法各个参数的意义

    1. 11.txt文件内容如下:

    1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950

    2. 程序如下:

    package com.xuzhiwen.io1;
    
    import java.io.File;
    import java.io.FileInputStream;
    
    public class InputStreamTest {
        public static void main(String[] args) throws Exception {
            String s = File.separator;
            File file = new File("E:"+s+"filetest"+s+"11.txt");
            FileInputStream in = new FileInputStream(file);
            int len;
            byte b[] = new byte[1024];
            while((len = in.read(b, 0, b.length)) !=-1){
                System.out.println(new String(b));
            }
        }
    }

    3.运行结果如下:

    4.修改红色字体代码

    package com.xuzhiwen.io1;
    
    import java.io.File;
    import java.io.FileInputStream;
    
    public class InputStreamTest {
        public static void main(String[] args) throws Exception {
            String s = File.separator;
            File file = new File("E:"+s+"filetest"+s+"11.txt");
            FileInputStream in = new FileInputStream(file);
            int len;
            byte b[] = new byte[1024];
            while((len = in.read(b, 0,20)) !=-1){
                System.out.println(new String(b));
            }
            in.close();
        }
    }

    5.运行结果如下:

    多出了红色框中的数据

  • 相关阅读:
    序列化 Serialization
    http soap关系
    sql 查询
    返回最后插入到标识列的值(scope_identity.ident_current.@@identity)
    匿名方法
    九、volatile与Java内存模型
    八、Java内存模型JMM
    十、CAS
    CUSTOM ROUTE CONSTRAINTS
    获取本地数据库
  • 原文地址:https://www.cnblogs.com/beibidewomen/p/7358372.html
Copyright © 2011-2022 走看看