贴吧用户_0092ae9 13586095160
关注数: 24 粉丝数: 153 发帖数: 8,883 关注贴吧数: 86
想在客户端里显示两行字,但是简单得用\n不行... 希望在输出时显示成这个样子: Client: 9.9 SERVER: 28.59 mpg          ECON: OK//这一行东西不知道该怎么弄用"\n"之后就不显示了. Client: 16.532 SERVER: ERR          ECON: OK 刚接触编程,什么都不懂,大家教教我吧. 客户端: public class EconClient {      public static void main(String[] args) throws IOException{          Socket   EcSocket = null;          PrintWriter out = null;          BufferedReader in = null;          try {              EcSocket = new Socket("localhost", 5555);              out = new PrintWriter(EcSocket.getOutputStream(), true);              in = new BufferedReader(new InputStreamReader(EcSocket.getInputStream()));          } catch (UnknownHostException e) {              System.err.println("Don't know about host.");              System.exit(1);          } catch (IOException e) {              System.err.println("Couldn't get I/O for the connection to host.");              System.exit(1);          }          BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));          String fromServer;          String fromUser;          while ((fromServer = in.readLine()) != null) {              System.out.println("Server: " + fromServer);              if (fromServer.equals("END: OK"))                  break;                           fromUser = stdIn.readLine();          if (fromUser != null) {                  System.out.println("Client: " + fromUser);                  out.println(fromUser);          }
首页 4 5 6 7 8 9 下一页