zoukankan      html  css  js  c++  java
  • 学习Java随记之IO编程

      输入输出流的判定是以内存为参照的,如果数据是从文件(数据源)向内存流动则为输入流,否则为输出流。

      字节流可以读写二进制文件及任意文件,而字符流只能读写文本文件

      字节流 字符流
    输入流 InputStream Reader
    输出流 OutPutStream Writer

      File file=new File("d:\**\**.txt");//其中文件路径也可这样写("d:/**/**.txt")

      File文件类的一些常用方法:

    1. file.mkdir():创建指定路径的文件夹
    2. file.createNewFile():创建指定路径的文件
    3. int file.length():获取文件的大小
    4. file[] file.listFiles():返回一个指定路径下的文件数组
    5. boolean file.exists():判断文件是否存在
    6. file.delete()文件删除
    7. boolean file.isDirectory():可用于判断文件夹是否存在
    8. String file.getName();顾名思义
    9. String file.getAbsolutePath();顾名思义

      读写文件的字节流2个方法:

          FileInputStream.read(byte[] b)

          FileOutPutStream.write(byte[] b)

      读写文件的字符流2个方法:

          FileReader.read(char[] ch)

          FileWriter.write(char[] ch)

      可以读写字符串String的缓存流:

          BufferedReader.readLine();

          BufferedWriter.write(String str)

      String类的常用函数或者常用方法:

    1. char charAt(int index):
    2. int indexOf(String str)与int lastindexOf(String str)
    3. String substring(int startpos,int endindex)与String substring(int startpos)
    4. string trim()
    5. byte[] getBytes()与char[] toCharArray()
    6. String replace(oldChar, newChar)  
    7. String replaceAll(regex, replacement)
    8. String[] split(String regex)
    9. boolean isEmpty()
    10. String.valueOf(int i)
    11. Integer.parseInt(String str)、Float.parseFloat(String str)
    12. boolean equals(String str)与boolean equalsIgnoreCase(String str)
    13. int compareTo(String str)与int compareToIgnoreCase(String str)
    14. boolean startsWith(String str)与boolean endsWith(String str)
    15. int length



  • 相关阅读:
    GitHub教程学习笔记1本地Git管理
    GitHub教程学习笔记2远程仓库和本地仓库
    图像分割方法综述
    println输出乱码
    ngshow,ngif区别
    isFile() exists() isDirectory()的区别
    File类中的list和listFiles方法
    mkdir与mkdirs的区别
    新建play项目eclipsify后导入eclipse后无法debug调试
    大龄屌丝自学笔记Java零基础到菜鸟021
  • 原文地址:https://www.cnblogs.com/hijackhou/p/8254083.html
Copyright © 2011-2022 走看看