记录瞬间

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文件的更多相关文章

  1. java操作Jacoco合并dump文件

    记录瞬间 import org.apache.maven.plugin.MojoExecutionException; import org.jacoco.core.tools.ExecFileLoa ...

  2. java操作Excel、PDF文件

    java操作Excel.PDF文件 分享者:Vashon 分享来源:CSDN博客 下面这些是在开发中用到的一些东西,有的代码贴的不是完整的,只是贴出了关于操作EXCEL的代码: jxl是一个*国人写的 ...

  3. Java读取并下载网络文件

      CreateTime--2017年8月21日10:11:07 Author:Marydon import java.io.ByteArrayOutputStream; import java.io ...

  4. java操作office和pdf文件java读取word,excel和pdf文档内容

    在平常应用程序中,对office和pdf文档进行读取数据是比较常见的功能,尤其在很多web应用程序中.所以今天我们就简单来看一下Java对word.excel.pdf文件的读取.本篇博客只是讲解简单应 ...

  5. JAVA代码实现下载单个文件,和下载打包文件

    //下载单个文件调用方法 /**     * response     * imgPath 下载图片地址    * fileName 保存下载文件名称    * @date 2015年4月14日 下午 ...

  6. 【转】Java生成plist下载ipa文件

    我们在上传ipa想要安装的时候必须要通过plist文件去下载,并且还要遵循 itms-services协议. 意思就是,第一步我们要生成一个plist文件, 第二步生成一个html文件,用来指向pli ...

  7. java操作FTP,实现文件上传下载删除操作

    上传文件到FTP服务器: /** * Description: 向FTP服务器上传文件 * @param url FTP服务器hostname * @param port FTP服务器端口,如果默认端 ...

  8. java操作office和pdf文件页面列表导出cvs,excel、pdf报表.

    在平常的开发中我们常常遇到不仅仅只是导出excel报表的情况.有时候也需要导出pdf或者CSV报 表.其实原理都差不多.刚开始本来不打算也这篇博客介绍这个的.感觉这篇博客和前面的博客有点雷同.原理基本 ...

  9. java web 怎么下载大文件(上百M)

    Java代码   ; ]; , )) != -) { , bytesRead); 13.               } 14.               toClient.write(buffer ...

随机推荐

  1. WEB测试重点

    1.功能测试:所实现的功能是否和需求一致:2.界面测试:界面是否美观,风格是否一致,文字内容是否正确:3.链接测试:打开链接速度是否合理:是否链接到正确的页面:是否有空白页面:4.性能测试:系统能支持 ...

  2. SQL Server Report Server 报表用户权限T-SQL查询

    /************************************************************************** 查询用户在报表上的权限 ************ ...

  3. Do-Now—团队冲刺博客四

    各个成员今日完成的任务 侯泽洋:完成奖励页面设计,完成奖励从云端拉取到本地:完成奖励从云端拉取到本地 周亚杰:冲刺博客,个人中心设计(未完成) 王志伟:积分页面设计:积分页面设计 仇夏:树苗成长过程设 ...

  4. flask之wtforms

    本篇导航: wtforms组件的使用 自定义From组件 一.wtforms组件的使用 1.flask中的wtforms WTForms是一个支持多个web框架的form组件,主要用于对用户请求数据进 ...

  5. CSS3_盒子背景

    盒子背景 盒子背景:content    padding    特殊的 boder 背景 背景绘制 从 padding 开始绘制 背景裁剪 background-clip(默认值 border-box ...

  6. Java课程寒假之《人月神话》有感之三

    一.未雨绸缪 作者开始谈论实验室代码如何向开发出来的产品转变,化学工程师通过“实验性工厂”的中间步骤做测试来得到经验.而软件系统的构建人员却是按照时间进度将第一次开发的产品发布给顾客.对于我这只没有实 ...

  7. 匿名函数function前面的! ~等符号作用小解

    好久没写博客了,刚过完年,给大家拜个晚年,大家新年快乐! 相信昨晚前端,很多同学应该都见过类似于: !function() {do something...}() ~function(){do som ...

  8. 如何查询注册表的值及 Powershell 应用

    利用 c:\windows\system32\reg.exe 的 query 参数即可. reg.exe 的参数如下: C:\windows\system32> reg.exe /?REG Op ...

  9. Robot Framework 1

    about Robot, learnt from the following document, perfect document !!!! http://www.virtuousprogrammer ...

  10. NOIP 2017 解题报告

    ---恢复内容开始--- NOIP 2017 的题真的很难啊,怪不得当年我这个萌新爆零了(当然现在也是萌新)越学越觉得自己什么都不会. 想要成为强者要把这些好题都弄懂弄透 至少现在6道题我都比较陌生 ...