文件操作IO流(字节流字符流转换流)
发布日期:2021-05-10 03:36:38 浏览次数:21 分类:精选文章

本文共 4440 字,大约阅读时间需要 14 分钟。

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������system������������������������������������������

OutputStream���������������������

OutputStream ������������������������������������������������������������������������������������������

  • close()������������������������������������������������
  • flush()������������������������������������������������������������������������
  • nullOutputStream()��������������������� OutputStream ���������������������������������������������
  • write(byte[] b)������������ b ������������������������������������
  • write(byte[] b, int off, int len)������������ b ��� off ������������������ len ������������
  • write(int b)������������������ b ������������������
  • FileOutputStream���������������������

    FileOutputStream ��� OutputStream ������������������������������������������������������������������������������������

  • FileOutputStream(File file)������������������������������������������������������
  • FileOutputStream(FileDescriptor fdobj)���������������������������������������������������
  • FileOutputStream(File file, boolean append)��������������������������������������������������������������������� append ��� true������������������������������������������������������������������
  • ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������

    InputStream���������������������

    InputStream ��� OutputStream ���������������������������������������������������������������������������

  • close()������������������������������������������
  • read()���������������������������������
  • read(byte[] b)��������������� b ���������������������������������������������������������������������������������-1 ������������������������������
  • FileInputStream���������������������

    FileInputStream ��� InputStream ������������������������������������������������������������������������������

  • FileInputStream(File file)������������������������������������������������������������
  • FileInputStream(FileDescriptor fdobj)���������������������������������������������������
  • ������������������������

    • close()������������������������������������
    • read()���������������������������������
    • read(byte[] b, int off, int len)������������������������ len ������������������ b ��� off ���������

    ���������

    ��������������������������������������������������������������������������������������������������������������������������� FileWriter ��� System.outPrintWriter���

    ���������������

    FileWriter ������������������������������������������������������������������������������������

    • write(char cbuf[])���������������������������������������������������
    • write(String s)��������������� s ���������������
    • append(char cbuf[])��������������������������� cbuf ���������������������������������������������������

    ���������������

    FileWriter fw = new FileWriter("c://b.txt", true);
    fw.append("���������������,���������������").flush();
    fw.close();

    ���������������

    FileReader ���������������������������������������������������������������������������������

    • read(char cbuf[])��������������������� cbuf ���������������
    • read(String s, int off, int len)��������������������� len ��������������������� s ��� off ���������

    ��������������������������������� EOFException ������������������������

    ���������

    ������������������������������������������������������������������������������������������������������������ InputStreamReader ���������������������������������

    InputStreamReader reader = new InputStreamReader(new FileInputStream("coding.txt"), "UTF-8");

    ���������

    PrintWriter ���������������������������������������������������������������������������������������

    • println()������������������������
    • printf()���������������������������

    ���������

    PrintWriter pw = new PrintWriter(new FileOutputStream("output.txt"));
    pw.println("������������������");
    pw.println("���������������" + new java.util.Date());
    pw.close();

    ���������������

    ���������������������������������������������������������������������

    BufferedReader br = new BufferedReader(new FileReader("bigfile.txt"));
    String text = br.readLine();
    br.close();

    Properties ��������� Properties ���

    Properties ������������������������������������������������������������

    • store(Writer writer, String common)
    • load()

    ������ Properties ���������������������������������������

    上一篇:多线程详解Java三种实现方式+线程安全问题+死锁问题+线程池
    下一篇:Java泛型详解

    发表评论

    最新留言

    留言是一种美德,欢迎回访!
    [***.207.175.100]2025年04月04日 20时27分10秒