缓存字节流-写coppy方法

package ba;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import java.util.*;

public class huancunTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Date d1=new Date();
		Date d2=new Date();
		long l1=d1.getTime();
		copy("G:/a.png","G:/test/a.png");
		long l2=d2.getTime();
		System.out.println(l2-l1);

	}
	public static void copy(String str,String des){
		File srcFile = new File(str);
		File desFile = new File(des);
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;

		try {
			bis = new BufferedInputStream(new FileInputStream(srcFile));
			bos = new BufferedOutputStream(new FileOutputStream(desFile));

			byte[]b=new byte[1024];
			int len=0;
			try {
				while((len=bis.read(b))>0){
					bos.write(b,0,len);
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(bis!=null){
				try {
					bis.close();
					bos.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

	}

}
时间: 2024-08-04 05:05:07

缓存字节流-写coppy方法的相关文章

CodeIgniter的缓存机制与使用方法

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 数据库缓存 数据库缓存类允许你把数据库查询结果保存在文本文件中以减少数据库访问. 激活缓存需要三步:     在服务器上创建一个可写的目录以便保存缓存文件

ASP.Net 更新页面输出缓存的几种方法

ASP.Net 自带的缓存机制对于提高页面性能有至关重要的作用,另一方面,缓存的使用也会造成信息更新的延迟.如何快速更新缓存数据,有时成了困扰程序员的难题.根据我的使用经验,总结了下面几种方法,概括了常见的几种情况,如有更好的方法欢迎补充. (1)代码级缓存(对象缓存) Cache 对象 Cache 对象提供代码级的缓存,功能强大,可操作性强.更新这种缓存的方法很简单,只要调用 Cache.Remove(key) 方法就可以清除指定的缓存.代码如下: HttpRuntime.Cache.Remo

android 使用泛型再也不写findViewById方法了

我们在开发中肯定会findViewById寻找view,如果一个界面上有很多view需要绑定click事件,那么findViewById就是个体力活了,那我们就想能不能有一种办法能不能不必要每次去findViewById呢?只要你去想,说明你就意识到这个问题,剩下来就是想办法如何解决了,这个问题也不能,如果熟悉javase中的泛型,就会很简单的解决,代码入下 public <T> T $(int viewID) { return (T)findViewById(viewID); } 我们只要在

jQuery中ajax的使用与缓存问题的解决方法

jQuery中ajax的使用与缓存问题的解决方法 1:GET访问 浏览器 认为 是等幂的就是 一个相同的URL 只有一个结果[相同是指 整个URL字符串完全匹配]所以 第二次访问的时候 如果 URL字符串没变化 浏览器是 直接拿出了第一次访问的结果 POST则 认为是一个 变动性 访问 (浏览器 认为 POST的提交 必定是 有改变的) 防止 GET 的 等幂 访问 就在URL后面加上 ?+new Date();,[总之就是使每次访问的URL字符串不一样的] 设计WEB页面的时候 也应该遵守这个

模板类和模板函数的声明和定义分开文件写的方法

据说模板类和模板函数的声明和定义要写在同一个文件. 不然编译会出现"未定义的引用". 其实是有解决方法的. 模板类 template class CNNConvLayer<double>; 就是 template class className<typeName>; 模板函数 template void poolBackPropForKernal<double>(double*, double*, int, int, double*, double*

iOS清理缓存的几种方法

iOS清理缓存的几种方法,有需要的朋友可以参考下: 1.计算文件大小: - (long long) fileSizeAtPath:(NSString*) filePath{ NSFileManager* manager = [NSFileManager defaultManager]; if ([manager fileExistsAtPath:filePath]){ return [[manager attributesOfItemAtPath:filePath error:nil] file

服务器缓存占用的处理方法

Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. To free pagecache: * echo 1 > /proc/sys/vm/drop_caches             默认这种方式处理就可以 To free dentries and inodes: * echo 2 > /

裴东辉-在jsp页面中使用&lt;%!%&gt;写java方法

<%!%>是声明标签 因为Jsp页在到tomcat的时候会被编译为java文件 jsp页面里面的所有东西都会包含在一个方法里 如果不用声明标签去声明这是个方法 就会报错了 因为方法里面不能有方法 裴东辉-在jsp页面中使用<%!%>写java方法

js清除浏览器缓存的几种方法

关于浏览器缓存 浏览器缓存,有时候我们需要他,因为他可以提高网站性能和浏览器速度,提高网站性能.但是有时候我们又不得不清除缓存,因为缓存可能误事,出现一些 错误的数据.像股票类网站实时更新等,这样的网站是不要缓存的,像有的网站很少更新,有缓存还是比较好的.今天主要介绍清除缓存的几种方法. 清理网站缓存的几种方法 meta方法 //不缓存 <META HTTP-EQUIV="pragma" CONTENT="no-cache"> <META HTTP