如何解决java.net.SocketTimeoutException: Read timed out这个问题?
hlf 2012-03-01 02:59:52 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException{
ByteArrayOutputStream out = null;
String result = null;
try{
InputStream in = request.getInputStream();
out = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int len;
while ((len=in.read(buffer, 0, buffer.length))>-1){ 这句报错!!!
try {
out.write(buffer, 0, len);
} catch (Exception e) {
}
}
out.flush();
result = new String(out.toByteArray(),"utf-8");
}catch(Exception Ex){
//logger.error("",e);
}finally{
if (out!=null) out.close();
if (in!=null) in.close();
}
执行到上面那行代码时,报以下错误:
java.net.SocketTimeoutException: Read timed out
而我在本机测试了N次都没出现,放到生产环境后就偶尔会出现。并且我在生产环境上测试时也没出现,咋搞?