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 ...
随机推荐
- 2019-2-14sql server数据库模糊查询语句
sql server数据库模糊查询语句 确切匹配: select * from hs_user where ID=123 模糊查询 select * from hs_user where ID l ...
- 《Ray Tracing in One Weekend》、《Ray Tracing from the Ground Up》读后感以及光线追踪学习推荐
<Ray Tracing in One Weekend> 优点: 相对简单易懂 渲染效果相当好 代码简短,只看书上的代码就可以写出完整的程序,而且Github上的代码是将基类与之类写在一起 ...
- Django与supervisor 管理进程
1.前言 在Django项目中,我们需要用到一些独立于Django框架外的脚本.这样一些脚本可能需要独立的持续运行,且具有很强的可维护性,这个时候supervisor就可以排上用场了. 基于pytho ...
- Python 中的单例模式
单例模式 单例模式(Singleton Pattern)是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实例存在.当你希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场. ...
- Lesnoe Ozero 2016. BSUIR Open 2016 Finals
A. Street magic 数位DP,设$f[i][j][k]$表示从低到高考虑$x$的后$i$位,$x$和$m$大小关系为$j$,和$n$大小关系为$k$的方案数. #include<cs ...
- react-native 打开设置界面
iOS iOS打开设置还是比较简单的,使用Linking组件即可: Linking.openURL('app-settings:') .catch(err => console.log('err ...
- 在Linux下开发多语言软件(gettext解决方案)
最近的项目出现了一个bug.项目是基于一个已有的成熟开源软件之上做修改的,新写了加解密库,用于为该成熟开源软件增添加解密功能.功能增加完成后效果都很好,可是就是中文出不来了,也就是说没办法自适应多语言 ...
- [LeetCode] Split BST 分割二叉搜索树
Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two ...
- mysql having和where的区别
having子句与where子句一样,都是用于条件判断的. 区别1 where是判断数据从磁盘读入内存的时候 having是判断分组统计之前的所有条件 区别原理 区别2 having子句中可以使用字段 ...
- 白盒测试实践-day04
一.任务进展情况 通过小组成员的共同努力,终于完成了此次“白盒测试实践”任务.目前的主要任务将之前的文件汇总,整理出来. 二.存在的问题 由于测试系统的不完善,导致单元测试比较麻烦. 三.解决方法 认 ...