java.lang.Object
jdk.jfr.consumer.RecordingFile
- All Implemented Interfaces:
- Closeable,- AutoCloseable
A recording file.
 
The following example shows how read and print all events in a recording file.
try (RecordingFile recordingFile = new RecordingFile(Paths.get("recording.jfr"))) {
    while (recordingFile.hasMoreEvents()) {
        RecordedEvent event = recordingFile.readEvent();
        System.out.println(event);
    }
}
- Since:
- 9
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes this recording file and releases any system resources that are associated with it.booleanReturnstrueif unread events exist in the recording file,falseotherwise.static List<RecordedEvent> readAllEvents(Path path) Returns a list of all events in a file.Reads the next event in the recording.Returns a list of all event types in this recording.voidwrite(Path destination, Predicate<RecordedEvent> filter) Filter out events and write them to a new file.
- 
Constructor Details- 
RecordingFileCreates a recording file.Only recording files from trusted sources should be used. - Parameters:
- file- the path of the file to open, not- null
- Throws:
- IOException- if it's not a valid recording file, or an I/O error occurred
- NoSuchFileException- if the- filecan't be located
- SecurityException- if a security manager exists and its- checkReadmethod denies read access to the file.
 
 
- 
- 
Method Details- 
readEventReads the next event in the recording.- Returns:
- the next event, not null
- Throws:
- EOFException- if no more events exist in the recording file
- IOException- if an I/O error occurs
- See Also:
 
- 
hasMoreEventspublic boolean hasMoreEvents()Returnstrueif unread events exist in the recording file,falseotherwise.- Returns:
- trueif unread events exist in the recording,- falseotherwise.
 
- 
readEventTypesReturns a list of all event types in this recording.- Returns:
- a list of event types, not null
- Throws:
- IOException- if an I/O error occurred while reading from the file
- See Also:
 
- 
closeCloses this recording file and releases any system resources that are associated with it.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException- if an I/O error occurred
 
- 
writeFilter out events and write them to a new file.- Parameters:
- destination- path where the new file should be written, not- null
- filter- filter that determines if an event should be included, not- null
- Throws:
- IOException- if an I/O error occurred, it's not a Flight Recorder file or a version of a JFR file that can't be parsed
- SecurityException- if a security manager exists and its- checkWritemethod denies write access to the file
- Since:
- 19
 
- 
readAllEventsReturns a list of all events in a file.This method is intended for simple cases where it's convenient to read all events in a single operation. It isn't intended for reading large files. Only recording files from trusted sources should be used. - Parameters:
- path- the path to the file, not- null
- Returns:
- the events from the file as a Listobject; whether theListis modifiable or not is implementation dependent and therefore not specified, notnull
- Throws:
- IOException- if an I/O error occurred, it's not a Flight Recorder file or a version of a JFR file that can't be parsed
- SecurityException- if a security manager exists and its- checkReadmethod denies read access to the file.
 
 
-