简体   繁体   中英

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). Is there a way how to get such recorded data in form of byte[] .

Preferably without external dependencies. I'm aware of implementing custom in-memory 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 ? That's the only API on Recording that might possibly suggest a way to do it. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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