`
gybmike
  • 浏览: 180127 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

簡單的文件拷貝

    博客分类:
  • java
阅读更多

    public static boolean copyTo( String sDest , String sSource ) throws Exception {
    	FileInputStream fi = new FileInputStream( sSource );
    	try {
    		FileOutputStream fo = new FileOutputStream( sDest ,false );
    		try {
    			fo.getChannel().tryLock();
    			byte buf [] = new byte[4096];
    			int readed;
    			while( (readed = fi.read(buf)) != -1 ) {
    				fo.write(buf, 0 , readed);
    			}
    		} finally {
    			fo.close();
    		}
    	} finally {
    		fi.close();
    	}
    	return true;
    
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics