zoukankan      html  css  js  c++  java
  • 读mingjava io系列文章有感

    针对文件的操作:
    File类:主要是有4种构造函数
    主要的方法exists(),mkdir(),mkdirs(),is...(),get...(),list(),create...()    ...表示有一系列方法


    对二进制文件来说,首先使用File指定要获得文件或者是待存储的目标文件,接着使用两个类:FileInputStream和FileOutputStream,他们使用File类做为参数.

    FileInputStream中值得关注的是read的三个重载的方法.无参数,buffer参数,buffer/offset/length参数

    文本文件
            主要是使用了Reader和Writer两个类.这两个类都是抽象类,Writer中write(char[] ch,int off,int length),flush()和close()方法为抽象方法,Reader中read(char[] ch,int off,int length)和close()方法是抽象方法。常用的有他们的子类..以读入为例.FileReader,InputStreamReader和BufferedReader
    高效的用法
     BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("ming.txt")));
      String data = null;
      while((data = br.readLine())!=null)
      {
       System.out.println(data); 
      }

    针对数据类型的操作:
             基本数据类型包括byte、int、char、long、float、double、boolean和short
            与FileInputStream和FileOutputStream对应的有DataInputStream和DataOutputStream.同样以DataInputStream讨论,他继承自FilterInputStream.并且实现了DataInput和DataOutput两个接口,这个两个接口的功能就是把二进制的字节流转换成Java的基本数据类型,还提供了从数据中使用UTF-8编码构建String的功能.
    DataInputStream可以处理UTF也就是可以处理中文...
    loop's blog
  • 相关阅读:
    sys、os 模块
    sh 了解
    TCP协议的3次握手与4次挥手过程详解
    python argparse(参数解析)模块学习(二)
    python argparse(参数解析)模块学习(一)
    Day17--Python--面向对象--成员
    Day16--Python--初识面向对象
    Day14--Python--函数二,lambda,sorted,filter,map,递归,二分法
    Day013--Python--内置函数一
    Day12--Python--生成器,生成器函数,推导式,生成器表达式
  • 原文地址:https://www.cnblogs.com/goodloop/p/51126.html
Copyright © 2011-2022 走看看