Skip to content

message.writeDICOMToFile

Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.writeDICOMToFile.

Signature: message.writeDICOMToFile(filePath)

Returns: void

Streams the current 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.

Parameters

Type Name Description Default
String filePath the path of the file to create; an existing file is overwritten

Example

// Given a DICOM message (message)
// Stream the DICOM message to disk with the proper file preamble and File Meta Information
message.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)