java-day19

 

第十九天:

1,File

2,流的分类 BIO   NIO   AIO

3,BIO分类:I/O  input/output     读/写

   1)按流向:输入流   输出流

   2)读取方式:字节流   字符流

   字节输入流(InputStream)   字节输出流(OutputStream)   字符输入流  字符输出流

   

4,文件复制   

5,加密

 

6,文件夹复制

 

编码

ASSIC:0-127

      0-32768

GBK

GB2312

utf-8

 

 

 

 Test

import java.io.*;

import java.util.Date;

 

public class Test {

    public static void main(String[] args) throws Exception {

        /*try {

            InputStream is = new FileInputStream("d://a/asd.txt");

            //int i = is.read();

            byte[] b = new byte[1024];

 

            int i = is.read(b);

            //is.read(b,0,i);

            String str = "";

            while(i>0){

                str += new String(b,0,i);

                i = is.read(b);

            }

            System.out.println(str);

        } catch (Exception e) {

            e.printStackTrace();

        }*/

 

        /*OutputStream os = new FileOutputStream("d://a/zxc.txt",true);

        String s = "songxiaobao";

        os.write(s.getBytes());

        os.flush();*/

        long time1 = new Date().getTime();

        FileInputStream fis = new FileInputStream("c://rspider.zip");

        FileOutputStream fos = new FileOutputStream("c://a/rspider.zip",true);

        byte[] b = new byte[1024];

        int i = fis.read(b);

        while(i>0){

            byte[] bs = new byte[1024];

            int index = 0;

            for(int j=b.length-1;j>=0;j--){

                bs[index++] = b[j];

            }

            fos.write(bs,0,i);

            i = fis.read(b);

        }

        fos.flush();

        long time2 = new Date().getTime();

        System.out.println(time2-time1);

    }

}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值