日期:2014-05-20 浏览次数:21209 次
try {
URL url = new URL(BASE_URL + requestNumber + "/" + fileName);
File outFile = new File(path + File.separator + fileName);
os = new FileOutputStream(outFile);
is = url.openConnection().getInputStream();
byte[] buff = new byte[1024];
while (true) {
int readed = is.read(buff);
System.out.println("--------------" + buff.length);
if (readed == -1) {
break;
}
byte[] temp = new byte[readed];
System.arraycopy(buff, 0, temp, 0, readed);
os.write(temp);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
is.close();
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}