IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope: Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    
跳转到主要内容

developerWorks 中国  >  XML  >

Building an XML-based message server

An illustrative example of an XML-based message server

developerWorks

Return to article

private String readSocket() throws IOException {
   //first line contains the message length
   String line = in.readLine();
   int headerMessageLength = Integer.parseInt(line);
	
   //read lines from socket until the entire message length has been read
   StringBuffer sb = new StringBuffer();
   int incrementalMessageLength = 0;
   line = in.readLine();
   incrementalMessageLength += line.length() + 1;
   sb.append(line);
   while (incrementalMessageLength < headerMessageLength) {
      line = in.readLine();
      incrementalMessageLength += line.length() + 1; //add 1 for new line char
      sb.append(line);
   }
   return sb.toString();
}

Return to article

    关于 IBM 隐私条约 联系 IBM 使用条款