zoukankan      html  css  js  c++  java
  • 文件生成(做测试时使用)

    public class test {

    /**
    * @param args
    * @throws Exception 
    */
    public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    File f = new File("c:\\aa.pdf");
    for(int i=0;i<1100;i++)
    {
    File n = new File("c:\\pdf\\REPORT_1306460911500"+i+".pdf");
    forChannel(f,n);
    }
    }
    public static long forChannel(File f1,File f2) throws Exception{
           long time=new Date().getTime();
           int length=2097152;
           FileInputStream in=new FileInputStream(f1);
           FileOutputStream out=new FileOutputStream(f2);
           FileChannel inC=in.getChannel();
           FileChannel outC=out.getChannel();
           ByteBuffer b=null;
           while(true){
               if(inC.position()==inC.size()){
                   inC.close();
                   outC.close();
                   return new Date().getTime()-time;
               }
               if((inC.size()-inC.position())<length){
                   length=(int)(inC.size()-inC.position());
               }else
                   length=2097152;
               b=ByteBuffer.allocateDirect(length);
               inC.read(b);
               b.flip();
               outC.write(b);
               outC.force(false);
           }
       }
    }
  • 相关阅读:
    【NOIp】NOIp2015
    【题解】Luogu P2899 [USACO008JAN] 手机网络 树形dp
    「EZEC-4.5」走方格
    ZJOI2013 K大数查询
    CF765F Souvenirs
    [Vani有约会] 雨天的尾巴 /【模板】线段树合并
    中国剩余定理(CRT / EXCRT)
    洛谷 P1516 青蛙的约会
    CQOI2009 叶子的染色
    CSP2019 Emiya 家今天的饭
  • 原文地址:https://www.cnblogs.com/kevinge/p/2079426.html
Copyright © 2011-2022 走看看