String photoUrl="XXX";// HTTP请求返回文件流
Sting fileTemp_path="/test/test.jsp"; //保存的文件流
// 此方法只能用户HTTP协议
URL url = new URL(photoUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
DataInputStream in = new DataInputStream(connection.getInputStream());
DataOutputStream out = new DataOutputStream(new FileOutputStream(
fileTemp_path));
buffer = new byte[65536];
int count = 0;
while ((count = in.read(buffer)) > 0) {
out.write(buffer, 0, count);
}
out.close();
in.close();
Sting fileTemp_path="/test/test.jsp"; //保存的文件流
// 此方法只能用户HTTP协议
URL url = new URL(photoUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
DataInputStream in = new DataInputStream(connection.getInputStream());
DataOutputStream out = new DataOutputStream(new FileOutputStream(
fileTemp_path));
buffer = new byte[65536];
int count = 0;
while ((count = in.read(buffer)) > 0) {
out.write(buffer, 0, count);
}
out.close();
in.close();