Example #1
0
  private String ReadWholeFileToString(String filename) {

    File file = new File(filename);
    StringBuffer contents = new StringBuffer();
    BufferedReader reader = null;

    try {
      reader = new BufferedReader(new FileReader(file));
      String text = null;

      // repeat until all lines is read
      while ((text = reader.readLine()) != null) {
        contents.append(text).append(System.getProperty("line.separator"));
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (reader != null) {
          reader.close();
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    // show file contents here
    return contents.toString();
  }
Example #2
0
  public String getTestXmlString() {
    StringBuffer sb = new StringBuffer();

    // sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    // sb.append("<m:FindFolderResponse
    // xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"
    // xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">");
    // sb.append("<m:ResponseMessages>");
    // sb.append("<m:FindFolderResponseMessage ResponseClass=\"Error\">");
    // sb.append("<m:MessageText>SMTP 地址没有与其关联的邮箱。</m:MessageText>");
    // sb.append("<m:ResponseCode>ErrorNonExistentMailbox</m:ResponseCode>");
    // sb.append("<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>");
    // sb.append("<m:MessageXml>");
    // sb.append("<t:Value
    // Name=\"SmtpAddress\">[email protected]</t:Value>");
    // sb.append("</m:MessageXml>");
    // sb.append("</m:FindFolderResponseMessage>");
    // sb.append("</m:ResponseMessages>");
    // sb.append("</m:FindFolderResponse>");

    sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    sb.append("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
    sb.append("    <s:Body>");
    sb.append("        <s:Fault>");
    sb.append(
        "            <faultcode xmlns:a=\"http://schemas.microsoft.com/exchange/services/2006/types\">a:ErrorNonExistentMailbox</faultcode>");
    sb.append("            <faultstring xml:lang=\"zh-CN\">SMTP 地址没有与其关联的邮箱。</faultstring>");
    sb.append("            <detail>");
    sb.append(
        "                <e:ResponseCode xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">ErrorNonExistentMailbox</e:ResponseCode>");
    sb.append(
        "                <e:Message xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">SMTP 地址没有与其关联的邮箱。</e:Message>");
    sb.append(
        "                <t:MessageXml xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">");
    sb.append(
        "                    <t:Value Name=\"SmtpAddress\">[email protected]</t:Value>");
    sb.append("                </t:MessageXml>");
    sb.append("            </detail>");
    sb.append("        </s:Fault>");
    sb.append("    </s:Body>");
    sb.append("</s:Envelope>");

    return sb.toString();
  }