简体   繁体   English

Java Flight Recorder:将数据记录为字节数组

[英]Java Flight Recorder: Recording data as a byte array

Recording allows to save recorded data into file using dump() method (as shown in example below copied from the javadoc). Recording允许使用dump()方法将记录的数据保存到文件中dump()如下面从 javadoc 复制的示例所示)。 Is there a way how to get such recorded data in form of byte[] .有没有办法以byte[]形式获取这样的记录数据。

Preferably without external dependencies.最好没有外部依赖。 I'm aware of implementing custom in-memory FileSystem .我知道实现自定义内存中FileSystem

   Configuration c = Configuration.getConfiguration("default");
   Recording r = new Recording(c);
   r.start();
   System.gc();
   Thread.sleep(5000);
   r.stop();
   r.dump(Files.createTempFile("my-recording", ".jfr"));

Are you looking for getStream ?您在寻找getStream吗? That's the only API on Recording that might possibly suggest a way to do it.这是Recording上唯一可能建议一种方法的 API。 Other than that, you'll pretty much have to use dump to a Path , either to an in-memory filesystem or maybe even to an actual temporary file.除此之外,您几乎必须使用dumpPath ,或者到内存文件系统,或者甚至到实际的临时文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM