java文件流转文件
**public static void getFile(String url, String destFileName) {
String result = null;
HttpClient httpClient = null;
try {
httpClient = new SSLClient();
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("111", "111");
httpGet.setHeader("111", "111");
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
File file = new File(destFileName);
try {
FileOutputStream fout = new FileOutputStream(file);
int l = -1;
byte[] tmp = new byte[1024];
while ((l = in.read(tmp)) != -1) {
fout.write(tmp, 0, l);
// 注意这里如果用OutputStream.write(buff)的话,图片会失真,大家可以试试
}
fout.flush();
fout.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 关闭低层流。
in.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}**