zoukankan      html  css  js  c++  java
  • java复制文件范例代码

    	String url1 = "F:\SuperMap-Projects\region.udb";// 源文件路径
           
            try {
            	for(int i=1;i<101;i++){
            		 String url2 = "F:\SuperMap-Projects\region"+i+".udb";// 目标路径(复制到E盘,重命名为b.txt)
            		 copy(url1, url2);
            	}
    			
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
            
            
       
    
    	private static void copy(String url1, String url2) throws Exception {
    		FileInputStream in = new FileInputStream(new File(url1));
    		FileOutputStream out = new FileOutputStream(new File(url2));
    		byte[] buff = new byte[512];
    		int n = 0;
    		System.out.println("复制文件:" + "
    " + "源路径:" + url1 + "
    " + "目标路径:"
    				+ url2);
    		while ((n = in.read(buff)) != -1) {
    			out.write(buff, 0, n);
    		}
    		out.flush();
    		in.close();
    		out.close();
    		System.out.println("复制完成");
    	}
    

      

  • 相关阅读:
    1065 01字符串
    poj 1321 棋盘问题
    0608模拟算法试题
    唯一的雪花
    2969 角谷猜想
    0607枚举算法试题
    3162 抄书问题(划分dp)
    8782:乘积最大(划分dp)
    2985:数字组合
    3531:判断整除
  • 原文地址:https://www.cnblogs.com/yaohuimo/p/11186527.html
Copyright © 2011-2022 走看看