java文件io操作

    FileReader fr=new FileReader("D:\Demo.txt");
    char[] ch=new char[2];
    int len=0;
    while((len=fr.read(ch))!=-1)
    {
        System.out.print(new String(ch, 0, len));
    }
    FileReader fr=new FileReader("D:\Demo.txt");
    int cl=0;
    while((cl=fr.read())!=-1)
    {
        System.out.println((char)cl);
    }
        FileInputStream fs=new FileInputStream("D:\2.avi");
        FileOutputStream fo=new FileOutputStream("D:\3.avi");
        byte[] buf=new byte[1024];
        int len=0;
        while((len=fs.read(buf))!=-1)
        {
            fo.write(buf,0,len);
        }
        
        fs.close();
        fo.close();
原文地址:https://www.cnblogs.com/zywf/p/4767693.html