`

上传文件工具

 
阅读更多

// 上传文件

public void upload(File startpath, String endpath) throws Exception {

InputStream is = new FileInputStream(startpath);

int c = is.available();

if (c > 1024 * 1024 * 20) {

}

OutputStream os = new FileOutputStream(new File(endpath));

byte[] buffer = new byte[500];

int length = 0;

while (-1 != (length = is.read(buffer, 0, buffer.length))) {

os.write(buffer);

}

os.close();

is.close();

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics