Android异常总结---1.Android java.net.SocketException: Address family not supported by protocol

1.Android java.net.SocketException: Address family not supported by protocol 出错提示 
  这个异常是因为

package com.credram.servlet;



import java.io.IOException;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.credream.util.StreamTool;
public class XmlServlet extends HttpServlet {
private static final long serialVersionUID = 1L;


@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
 
//super.doGet(req, resp);//以上很多错误都是因为多了这句话造成的.,因为父类的这个方法,默认的返回是405的错误,所以会报这个错误
}


@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//1.web应用需要取得android应用发来的http协议封装的实体数据
try
{
//2.使用工具类,自己写的,读取传来的数据
  byte[] data=StreamTool.read(request.getInputStream());
String xml=new String(data,"UTF-8");
//3.这里需要知道,android系统用的是utf-8编码,而本机用的是gbk编码所以这里需要转码
System.out.println(xml);
} catch (Exception e)
{
e.printStackTrace();
}
}


}

你可能感兴趣的:(Android异常总结---1.Android java.net.SocketException: Address family not supported by protocol)