上传文件工具

// 上传文件

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();

}

猜你喜欢

转载自zhitangrui2010.iteye.com/blog/2237527