java操作JacocClient下载dump文件
记录瞬间
import org.jacoco.core.data.ExecutionDataWriter;
import org.jacoco.core.runtime.RemoteControlReader;
import org.jacoco.core.runtime.RemoteControlWriter; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.List; /**
* This example connects to a coverage agent that run in output mode
* <code>tcpserver</code> and requests execution data. The collected data is
* dumped to a local file.
*/
public class ExecutionDataClient { public String downLoadDump(String path, List<String> ipPort) {
int flag = 0;
String getDirName = getDirNum(path);
for (String getIPPost : ipPort){
String dirName = getDirName + "/" + getIPPost.replace(":", "_") + "_jacoco.exec";
String ip = getIPPost.split(":")[0];
int port = Integer.parseInt(getIPPost.split(":")[1]);
try {
final FileOutputStream localFile = new FileOutputStream(dirName);
final ExecutionDataWriter localWriter = new ExecutionDataWriter(
localFile);
// Open a socket to the coverage agent:
final Socket socket = new Socket(InetAddress.getByName(ip), port);
final RemoteControlWriter writer = new RemoteControlWriter(
socket.getOutputStream());
final RemoteControlReader reader = new RemoteControlReader(
socket.getInputStream());
reader.setSessionInfoVisitor(localWriter);
reader.setExecutionDataVisitor(localWriter); // Send a dump command and read the response:
writer.visitDumpCommand(true, false);
if (!reader.read()) {
throw new IOException("Socket closed unexpectedly.");
} socket.close();
localFile.close();
System.out.println("Download file success....");
System.out.println("File path is : " + dirName);
flag ++;
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
if (flag != 0) {
return getDirName;
} else {
return "path";
}
} /**
*
* @param path
* @return
*/
private String getDirNum(String path){
File file = null;
String newPath = "";
for (int i = 0 ; ; i++) {
newPath = path + "/" + i;
file = new File(newPath);
System.out.println("new path = "+newPath);
if (! file.isDirectory()) {
System.out.println(newPath);
file.mkdirs();
break;
}
}
return newPath;
}
}
记录通过Jacoco 客户端,获取远端服务器上的dump文件。
java操作JacocClient下载dump文件的更多相关文章
- java操作Jacoco合并dump文件
记录瞬间 import org.apache.maven.plugin.MojoExecutionException; import org.jacoco.core.tools.ExecFileLoa ...
- java操作Excel、PDF文件
java操作Excel.PDF文件 分享者:Vashon 分享来源:CSDN博客 下面这些是在开发中用到的一些东西,有的代码贴的不是完整的,只是贴出了关于操作EXCEL的代码: jxl是一个*国人写的 ...
- Java读取并下载网络文件
CreateTime--2017年8月21日10:11:07 Author:Marydon import java.io.ByteArrayOutputStream; import java.io ...
- java操作office和pdf文件java读取word,excel和pdf文档内容
在平常应用程序中,对office和pdf文档进行读取数据是比较常见的功能,尤其在很多web应用程序中.所以今天我们就简单来看一下Java对word.excel.pdf文件的读取.本篇博客只是讲解简单应 ...
- JAVA代码实现下载单个文件,和下载打包文件
//下载单个文件调用方法 /** * response * imgPath 下载图片地址 * fileName 保存下载文件名称 * @date 2015年4月14日 下午 ...
- 【转】Java生成plist下载ipa文件
我们在上传ipa想要安装的时候必须要通过plist文件去下载,并且还要遵循 itms-services协议. 意思就是,第一步我们要生成一个plist文件, 第二步生成一个html文件,用来指向pli ...
- java操作FTP,实现文件上传下载删除操作
上传文件到FTP服务器: /** * Description: 向FTP服务器上传文件 * @param url FTP服务器hostname * @param port FTP服务器端口,如果默认端 ...
- java操作office和pdf文件页面列表导出cvs,excel、pdf报表.
在平常的开发中我们常常遇到不仅仅只是导出excel报表的情况.有时候也需要导出pdf或者CSV报 表.其实原理都差不多.刚开始本来不打算也这篇博客介绍这个的.感觉这篇博客和前面的博客有点雷同.原理基本 ...
- java web 怎么下载大文件(上百M)
Java代码 ; ]; , )) != -) { , bytesRead); 13. } 14. toClient.write(buffer ...
随机推荐
- sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') #改变标准输出的默认编码
不论使用urllib还是使用requests库经常会遇到中文编码错误的问题,我就经常遇到,因为python安装在windows平台上,cmd的默认编码为GBK,所以在cmd中显示中文时会经常提示gbk ...
- Django聚合分组查询、常用字段
首先回顾sql中聚合和分组的概念: 如果没有分组,会把整张表作为一个大组,查询字段必须是聚合结果:如果有分组,分组之后,必须要使用聚合的结果作为having的条件. 聚合查询 聚合:aggregate ...
- PostgreSQL自学笔记:3 数据库的基本操作
3 数据库的基本操作 3.1 创建数据库 3.1.1 使用对象浏览器创建数据库 [Server] -> PostgreSQL 9.6 -> 数据库,右击 -> 创建 通常: 数据库: ...
- mac下启动mysql
mac下使用mysql有点蛋疼,每次都要找命令.可能不同版本或者安装方式mysql的位置不太一样, 可以使用locate mysql.server查找一下. # start sudo /usr/loc ...
- JS功能函数
1.整数每三位增加一个, function toThousands(num) { return (num || 0).toString().replace(/(\d)(?=(?:\d{3}) ...
- Grunt connect
使用connect打开指定html方法 由于localhost会直接链接到了index.html,所以我们可以通过base选项设置打开html,这是我的目录,我要打开根目录下的test.html co ...
- Python 在cmd中import模块成功,但是在jupyter notebook中No module xxx found
由于需要用到python中的某个库,因此打开命令行窗口cmd,然后使用pip安装.安装成功后,在cmd中输入python调出python环境,import该模块并使用,可以正常使用.但是打开juypt ...
- chrome浏览器上传图片反应很慢,延迟很久才弹出窗口
chrome浏览器上传图片反应很慢,延迟很久才弹出窗口 一个上传图片的控件,点击按钮上传图片,用chrome(谷歌浏览器)时,点击按钮后,要等好几秒才弹出文件选择窗口 可以试一下,把网络断开,这个问题 ...
- hadoop 学习笔记(第三章 Hadoop分布式文件系统 )
map->shuffle->reduce map(k1,v1)--->(k2,v2) reduce(k2,List<v2>)--->(k2,v3) 传输类型:org ...
- linux 编译静态库及动态库例子--from周立功文档
/* hello1.c */#include <stdio.h>int hello1 (void){printf("hello 1!\n");return 0;}/* ...