BufferedInputStream bis = null;
ByteArrayOutputStream bos = null;
FileOutputStream fos = null;
try
{
bis = new BufferedInputStream(requset.getInputStream());
bos = new ByteArrayOutputStream();
int len = 0;
// 读取
byte[] buffer = new byte[409600];
while ((len = bis.read(buffer)) > -1)
{
bos.write(buffer, 0, len);
}
byte[] allData = bos.toByteArray();
// 写入
fos = new FileOutputStream(new File("G://msc.jpg"));
fos.write(allData);
fos.flush();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
fos.close();
bos.close();
bis.close();
}
ByteArrayOutputStream bos = null;
FileOutputStream fos = null;
try
{
bis = new BufferedInputStream(requset.getInputStream());
bos = new ByteArrayOutputStream();
int len = 0;
// 读取
byte[] buffer = new byte[409600];
while ((len = bis.read(buffer)) > -1)
{
bos.write(buffer, 0, len);
}
byte[] allData = bos.toByteArray();
// 写入
fos = new FileOutputStream(new File("G://msc.jpg"));
fos.write(allData);
fos.flush();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
fos.close();
bos.close();
bis.close();
}