当前位置: 首页>>代码示例>>Java>>正文


Java StringBuilderPrinter.println方法代码示例

本文整理汇总了Java中android.util.StringBuilderPrinter.println方法的典型用法代码示例。如果您正苦于以下问题:Java StringBuilderPrinter.println方法的具体用法?Java StringBuilderPrinter.println怎么用?Java StringBuilderPrinter.println使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.util.StringBuilderPrinter的用法示例。


在下文中一共展示了StringBuilderPrinter.println方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHttpResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getHttpResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  HttpDesc desc = (HttpDesc) parameters;
  printer.println("[HTTP]");
  printer.println("URL: " + desc.url);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    int headerLen = Integer.parseInt(values.get("headers_len"));
    int bodyLen = Integer.parseInt(values.get("body_len"));
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("");
    printer.println("Downloaded " + (headerLen + bodyLen) + " bytes in " + time + " ms");
    printer.println("Bandwidth: " + (headerLen + bodyLen) * 8 / time + " Kbps");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Http paused!");
  } else {
    printer.println("Http download failed, status code " + values.get("code"));
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:22,代码来源:MeasurementResult.java

示例2: getDnsResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getDnsResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  DnsLookupDesc desc = (DnsLookupDesc) parameters;
  printer.println("[DNS Lookup]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    String ipAddress = removeQuotes(values.get("address"));
    if (ipAddress == null) {
      ipAddress = "Unknown";
    }
    printer.println("\nAddress: " + ipAddress);
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("Lookup time: " + time + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("DNS look up paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:22,代码来源:MeasurementResult.java

示例3: getHttpResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getHttpResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  HttpDesc desc = (HttpDesc) measurementDesc;
  printer.println("[HTTP]");
  printer.println("URL: " + desc.url);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    int headerLen = Integer.parseInt(values.get("headers_len"));
    int bodyLen = Integer.parseInt(values.get("body_len"));
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("");
    printer.println("Downloaded " + (headerLen + bodyLen) + " bytes in " + time + " ms");
    printer.println("Bandwidth: " + (headerLen + bodyLen) * 8 / time + " Kbps");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Http paused!");
  } else {
    printer.println("Http download failed, status code " + values.get("code"));
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:22,代码来源:MeasurementResult.java

示例4: getDnsResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getDnsResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  DnsLookupDesc desc = (DnsLookupDesc) measurementDesc;
  printer.println("[DNS Lookup]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    String ipAddress = removeQuotes(values.get("address"));
    if (ipAddress == null) {
      ipAddress = "Unknown";
    }
    printer.println("\nAddress: " + ipAddress);
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("Lookup time: " + time + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("DNS look up paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:22,代码来源:MeasurementResult.java

示例5: getPingResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getPingResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  PingDesc desc = (PingDesc) parameters;
  printer.println("[Ping]");
  printer.println("Target: " + desc.target);
  String ipAddress = removeQuotes(values.get("target_ip"));
  // TODO: internationalize 'Unknown'.
  if (ipAddress == null) {
    ipAddress = "Unknown";
  }
  printer.println("IP address: " + ipAddress);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    float packetLoss = Float.parseFloat(values.get("packet_loss"));
    int count = Integer.parseInt(values.get("packets_sent"));
    printer.println("\n" + count + " packets transmitted, " + (int) (count * (1 - packetLoss))
      + " received, " + (packetLoss * 100) + "% packet loss");

    float value = Float.parseFloat(values.get("mean_rtt_ms"));
    printer.println("Mean RTT: " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("min_rtt_ms"));
    printer.println("Min RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("max_rtt_ms"));
    printer.println("Max RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("stddev_rtt_ms"));
    printer.println("Std dev:  " + String.format("%.1f", value) + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Ping paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:37,代码来源:MeasurementResult.java

示例6: getUDPBurstResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getUDPBurstResult(StringBuilderPrinter printer, HashMap<String, String> values) {
    UDPBurstDesc desc = (UDPBurstDesc) parameters;
    if (desc.dirUp) {
      printer.println("[UDPBurstUp]");
    } else {
      printer.println("[UDPBurstDown]");
    }
    printer.println("Target: " + desc.target);
    printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
    printIPTestResult(printer);

    if (taskProgress == TaskProgress.COMPLETED) {
      printer.println("IP addr: " + values.get("target_ip"));
      printIPTestResult(printer);
//      printer.println("Packet size: " + desc.packetSizeByte + "B");
//      printer.println("Number of packets to be sent: " + desc.udpBurstCount);
//      printer.println("Interval between packets: " + desc.udpInterval + "ms");

      String lossRatio = String.format("%.2f", Double.parseDouble(values.get("loss_ratio")) * 100);
      String outOfOrderRatio =
          String.format("%.2f", Double.parseDouble(values.get("out_of_order_ratio")) * 100);
      printer.println("\nLoss ratio: " + lossRatio + "%");
      printer.println("Out of order ratio: " + outOfOrderRatio + "%");
      printer.println("Jitter: " + values.get("jitter") + "ms");
    } else if (taskProgress == TaskProgress.PAUSED) {
      printer.println("UDP Burst paused!");
    } else {
      printer.println("Error: " + values.get("error"));
    }
  }
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:31,代码来源:MeasurementResult.java

示例7: getRRCResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getRRCResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  printer.println("[RRC Inference]");
  if (taskProgress == TaskProgress.COMPLETED) {
    printer.println("Succeed!");
  }
  else {
    printer.println("Failed!");
  }
  printer.println("Results uploaded to server");
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:11,代码来源:MeasurementResult.java

示例8: getPingResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getPingResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  PingDesc desc = (PingDesc) measurementDesc;
  printer.println("[Ping]");
  printer.println("Target: " + desc.target);
  String ipAddress = removeQuotes(values.get("target_ip"));
  // TODO: internationalize 'Unknown'.
  if (ipAddress == null) {
    ipAddress = "Unknown";
  }
  printer.println("IP address: " + ipAddress);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    float packetLoss = Float.parseFloat(values.get("packet_loss"));
    int count = Integer.parseInt(values.get("packets_sent"));
    printer.println("\n" + count + " packets transmitted, " + (int) (count * (1 - packetLoss))
      + " received, " + (packetLoss * 100) + "% packet loss");

    float value = Float.parseFloat(values.get("mean_rtt_ms"));
    printer.println("Mean RTT: " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("min_rtt_ms"));
    printer.println("Min RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("max_rtt_ms"));
    printer.println("Max RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("stddev_rtt_ms"));
    printer.println("Std dev:  " + String.format("%.1f", value) + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Ping paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:37,代码来源:MeasurementResult.java

示例9: getUDPBurstResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getUDPBurstResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  UDPBurstDesc desc = (UDPBurstDesc) measurementDesc;
  if (desc.dirUp) {
    printer.println("[UDPBurstUp]");
  } else {
    printer.println("[UDPBurstDown]");
  }
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    printer.println("IP addr: " + values.get("target_ip"));
    printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
    printIPTestResult(printer);
    printer.println("Packet size: " + desc.packetSizeByte + "B");
    printer.println("Number of packets to be sent: " + desc.udpBurstCount);
    printer.println("Interval between packets: " + desc.udpInterval + "ms");

    String lossRatio = String.format("%.2f", Double.parseDouble(values.get("loss_ratio")) * 100);
    String outOfOrderRatio =
        String.format("%.2f", Double.parseDouble(values.get("out_of_order_ratio")) * 100);
    printer.println("\nLoss ratio: " + lossRatio + "%");
    printer.println("Out of order ratio: " + outOfOrderRatio + "%");
    printer.println("Jitter: " + values.get("jitter") + "ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("UDP Burst paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:32,代码来源:MeasurementResult.java

示例10: displayResults

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
public void displayResults(StringBuilderPrinter printer) {
  String DEL = "\t", toprint = DEL + DEL;
  for (int i = 1; i <= times.length; i++) {
    toprint += DEL + " | state" + i;
  }
  toprint += " |";
  int oneLineLen = toprint.length();
  toprint += "\n";
  // seperator
  for (int i = 0; i < oneLineLen; i++) {
    toprint += "-";
  }
  toprint += "\n";
  if (HTTP) {
    toprint += "HTTP (ms)" + DEL;
    for (int i = 0; i < httpTest.length; i++) {
      toprint += DEL + " | " + Integer.toString(httpTest[i]);
    }
    toprint += " |\n";
    for (int i = 0; i < oneLineLen; i++) {
      toprint += "-";
    }
    toprint += "\n";
  }

  if (DNS) {
    toprint += "DNS (ms)" + DEL;
    for (int i = 0; i < dnsTest.length; i++) {
      toprint += DEL + " | " + Integer.toString(dnsTest[i]);
    }
    toprint += " |\n";
    for (int i = 0; i < oneLineLen; i++) {
      toprint += "-";
    }
    toprint += "\n";
  }

  if (TCP) {
    toprint += "TCP (ms)" + DEL;
    for (int i = 0; i < tcpTest.length; i++) {
      toprint += DEL + " | " + Integer.toString(tcpTest[i]);
    }
    toprint += " |\n";
    for (int i = 0; i < oneLineLen; i++) {
      toprint += "-";
    }
    toprint += "\n";
  }

  toprint += "Timers (s)";
  for (int i = 0; i < times.length; i++) {
    double curTime = (double) times[i] * (double) GRANULARITY / 1000.0;
    toprint += DEL + " | " + String.format("%.2f", curTime);
  }
  toprint += " |\n";
  printer.println(toprint);
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:58,代码来源:RRCTask.java

示例11: getTracerouteResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getTracerouteResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  TracerouteDesc desc = (TracerouteDesc) parameters;
  printer.println("[Traceroute]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    // Manually inject a new line
    printer.println(" ");

    int hops = Integer.parseInt(values.get("num_hops"));
    int hop_str_len = String.valueOf(hops + 1).length();
    for (int i = 0; i < hops; i++) {
      String key = "hop_" + i + "_addr_1";
      String ipAddress = removeQuotes(values.get(key));
      if (ipAddress == null) {
        ipAddress = "Unknown";
      }
      String hop_str = String.valueOf(i + 1);
      String hopInfo = hop_str;
      for (int j = 0; j < hop_str_len + 1 - hop_str.length(); ++j) {
        hopInfo += " ";
      }
      hopInfo += ipAddress;
      // Maximum IP address length is 15.
      for (int j = 0; j < 16 - ipAddress.length(); ++j) {
        hopInfo += " ";
      }

      key = "hop_" + i + "_rtt_ms";
      // The first and last character of this string are double
      // quotes.
      String timeStr = removeQuotes(values.get(key));
      if (timeStr == null) {
        timeStr = "Unknown";
      }

      float time = Float.parseFloat(timeStr);
      printer.println(hopInfo + String.format("%6.2f", time) + " ms");
    }
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Traceroute paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:48,代码来源:MeasurementResult.java

示例12: getTCPThroughputResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getTCPThroughputResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  TCPThroughputDesc desc = (TCPThroughputDesc) parameters;
  if (desc.dir_up) {
    printer.println("[TCP Uplink]");
  } else {
    printer.println("[TCP Downlink]");
  }
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    printer.println("");
    // Display result with precision up to 2 digit
    String speedInJSON = values.get("tcp_speed_results");
    String dataLimitExceedInJSON = values.get("data_limit_exceeded");
    String displayResult = "";

    double tp = desc.calMedianSpeedFromTCPThroughputOutput(speedInJSON);
    double KB = Math.pow(2, 10);
    if (tp < 0) {
      displayResult = "No results available.";
    } else if (tp > KB * KB) {
      displayResult = "Speed: " + String.format("%.2f", tp / (KB * KB)) + " Gbps";
    } else if (tp > KB) {
      displayResult = "Speed: " + String.format("%.2f", tp / KB) + " Mbps";
    } else {
      displayResult = "Speed: " + String.format("%.2f", tp) + " Kbps";
    }

    // Append notice for exceeding data limit
    if (dataLimitExceedInJSON.equals("true")) {
      displayResult +=
          "\n* Task finishes earlier due to exceeding " + "maximum number of "
              + ((desc.dir_up) ? "transmitted" : "received") + " bytes";
    }
    printer.println(displayResult);
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("TCP Throughput paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:44,代码来源:MeasurementResult.java

示例13: getTracerouteResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getTracerouteResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  TracerouteDesc desc = (TracerouteDesc) measurementDesc;
  printer.println("[Traceroute]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    // Manually inject a new line
    printer.println(" ");

    int hops = Integer.parseInt(values.get("num_hops"));
    int hop_str_len = String.valueOf(hops + 1).length();
    for (int i = 0; i < hops; i++) {
      String key = "hop_" + i + "_addr_1";
      String ipAddress = removeQuotes(values.get(key));
      if (ipAddress == null) {
        ipAddress = "Unknown";
      }
      String hop_str = String.valueOf(i + 1);
      String hopInfo = hop_str;
      for (int j = 0; j < hop_str_len + 1 - hop_str.length(); ++j) {
        hopInfo += " ";
      }
      hopInfo += ipAddress;
      // Maximum IP address length is 15.
      for (int j = 0; j < 16 - ipAddress.length(); ++j) {
        hopInfo += " ";
      }

      key = "hop_" + i + "_rtt_ms";
      // The first and last character of this string are double
      // quotes.
      String timeStr = removeQuotes(values.get(key));
      if (timeStr == null) {
        timeStr = "Unknown";
      }

      float time = Float.parseFloat(timeStr);
      printer.println(hopInfo + String.format("%6.2f", time) + " ms");
    }
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Traceroute paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:48,代码来源:MeasurementResult.java

示例14: getTCPThroughputResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
private void getTCPThroughputResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  TCPThroughputDesc desc = (TCPThroughputDesc) measurementDesc;
  if (desc.dir_up) {
    printer.println("[TCP Uplink]");
  } else {
    printer.println("[TCP Downlink]");
  }
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    printer.println("");
    // Display result with precision up to 2 digit
    String speedInJSON = values.get("tcp_speed_results");
    String dataLimitExceedInJSON = values.get("data_limit_exceeded");
    String displayResult = "";

    double tp = desc.calMedianSpeedFromTCPThroughputOutput(speedInJSON);
    double KB = Math.pow(2, 10);
    if (tp < 0) {
      displayResult = "No results available.";
    } else if (tp > KB * KB) {
      displayResult = "Speed: " + String.format("%.2f", tp / (KB * KB)) + " Gbps";
    } else if (tp > KB) {
      displayResult = "Speed: " + String.format("%.2f", tp / KB) + " Mbps";
    } else {
      displayResult = "Speed: " + String.format("%.2f", tp) + " Kbps";
    }

    // Append notice for exceeding data limit
    if (dataLimitExceedInJSON.equals("true")) {
      displayResult +=
          "\n* Task finishes earlier due to exceeding " + "maximum number of "
              + ((desc.dir_up) ? "transmitted" : "received") + " bytes";
    }
    printer.println(displayResult);
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("TCP Throughput paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:44,代码来源:MeasurementResult.java

示例15: printIPTestResult

import android.util.StringBuilderPrinter; //导入方法依赖的package包/类
/**
 * Print ip connectivity and hostname resolvability result
 */
private void printIPTestResult(StringBuilderPrinter printer) {
  printer.println("IPv4/IPv6 Connectivity: " + properties.ipConnectivity);
  printer.println("IPv4/IPv6 Domain Name Resolvability: " + properties.dnResolvability);
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:8,代码来源:MeasurementResult.java


注:本文中的android.util.StringBuilderPrinter.println方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。