JAVA学习之路

常用链接

统计

最新评论

Java文件拷贝代码段

public

static void copy(String from, String to) throws IOException {

int BUFF_SIZE = 100000;

byte [] buffer = new byte [BUFF_SIZE];

InputStream in =

null ;

OutputStream out =

null ;

try {

in =

new FileInputStream(from);

out =

new FileOutputStream(to);

while ( true ) {

synchronized (buffer) {

int amountRead = in.read(buffer);

if (amountRead == -1) {

break ;

}

out.write(buffer, 0, amountRead);

}

}

}

finally {

if (in != null ) {

in.close();

}

if (out != null ) {

out.close();

}

}

}

posted on 2008-07-10 11:01 joaquin25 阅读(188) 评论(0)  编辑  收藏 所属分类: Java语言


只有注册用户登录后才能发表评论。


网站导航: