source.writeDICOMToFile¶
Use when: You want to read values from the original incoming message before any mapping changes. If you need the modified message during mapping, use message.writeDICOMToFile.
Signature: source.writeDICOMToFile(filePath)
Returns: void
Streams the source message to filePath as a valid DICOM file - preamble, File Meta Information, and pixel data included - without loading the object into memory.
Note
Unlike getDICOMBytesForFile(), nothing is buffered in memory, so this works for images of any size - including those larger than 2GB, which are too large to fit in a single byte array. Writing to a file does not modify the source message.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | filePath | the path of the file to create; an existing file is overwritten |
Example¶
// Given a DICOM source message (source)
// Stream the DICOM message to disk with the proper file preamble and File Meta Information
source.writeDICOMToFile("/tmp/streamed.dcm");
// Result:
// - /tmp/streamed.dcm is a valid DICOM file on disk
// - Works for messages of any size (nothing is held in memory)