作者:mobiledu2502872123 | 来源:互联网 | 2023-05-17 03:05
Ihavebeenstuckedinastrangeproblem.Iamusingorg.apache.http.impl.client.HttpClientapifor
I have been stucked in a strange problem. I am using org.apache.http.impl.client.HttpClient
api for an XML and media transfer beetween two web sites, now while reading a binary content (image in my case) from the web using DefaultHttpClient
only 1.9 kb of the image is saved. The problem is strange because the code works fine on my development environment (windows and ubuntu linux), but appears only on my production environment that is SUSE linux.
我一直陷入一个奇怪的问题。我正在使用org.apache.http.impl.client.HttpClient api进行两个网站之间的XML和媒体传输,现在在使用DefaultHttpClient从网络读取二进制内容(我的情况下的图像)时,只有1.9 kb的图像是保存。问题很奇怪,因为代码在我的开发环境(windows和ubuntu linux)上工作正常,但只出现在我的生产环境SUSE linux上。
below is the code i have used to save the file.
下面是我用来保存文件的代码。
HttpResponse respOnse= defaultHttpClient.execute(request);
InputStream stream = response.getEntity().getContent();
byte[] buffer = new byte[10024];
int count = stream.read(buffer);
buffer = Arrays.copyOf(buffer, count);
FileOutputStream fstream = new FileOutputStream("myFile.jpeg",true);
fstream.write(buffer, 0, count);
fstream.flush();
fstream.close();
stream.close();
Any help will be appreciated.
任何帮助将不胜感激。
Thanks
Shailesh.
3 个解决方案