标签:android io os ar java sp on art 问题
============问题描述============
public class Server extends Thread { @Override public void run() { // TODO Auto-generated method stub try { ServerSocket serverSocket=new ServerSocket(10000); System.out.println("Start Server"); while(true) { Socket socket=serverSocket.accept(); System.out.println("Get Socket"); int i=socket.getInputStream().read(); i++; socket.getOutputStream().write(i); socket.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String args[]) { new Server().start(); } }
textView=(TextView) findViewById(R.id.tv); button=(Button) findViewById(R.id.btn); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub try { Socket socket=new Socket("113.76.162.91", 10000); System.out.println("Build Socket"); socket.getOutputStream().write(12); System.out.println("Build Socket"); int i=socket.getInputStream().read(); socket.close(); textView.setText(String.valueOf(i)); } catch (UnknownHostException e) { // TODO Auto-generated catch block System.out.println("Unknow Host"); } catch (IOException e) { // TODO Auto-generated catch block System.out.println("IO Wrong"); } } });
============解决方案1============
============解决方案2============
标签:android io os ar java sp on art 问题
原文地址:http://www.cnblogs.com/llj1985522/p/4044484.html