标签:
public static String formatNetSpeed(long bytes) {
String result = size + " B/s";
if (size < 1<<10) {
} else if (size < 1<<20) {
result = String.format("%.1f KB/s", size*1.0 / (1<<10));
} else if (size < 1<<30) {
result = String.format("%.1f MB/s", size*1.0 / (1<<20));
} else if (size < 1<<40) {
result = String.format("%.1f GB/s", size*1.0 / (1<<30));
}
if (result.contains(".0")) {
result = result.replace(".0", "");
}
return result;
}
从配置文件中读取value, 例如keyStr=value时
getValueFromFile(filePath, keyStr, “=”)
public static String getValueFromFile(String filePath, String key, String seprator) {
if (TextUtils.isEmpty(filePath) || TextUtils.isEmpty(key)
|| seprator == null) {
return null;
}
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(new File(filePath)));
String line = null;
while ((line = reader.readLine()) != null) {
if (line.contains(key) && line.contains(seprator)) {
return line.substring(line.indexOf(seprator) + seprator.length());
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
monkey 自动测试
monkey -p com.brian.example –throttle 1000 -s 100 -v -v -v 15000 > /sdcard/monkey_test.txt
标签:
原文地址:http://blog.csdn.net/brian512/article/details/46565333