Dashboard > dcm4che-2.x > ... > Working with DICOM files > Writing DICOM files
Writing DICOM files Log In | Sign Up   View a printable version of the current page.

Added by Damien Evans , last edited by Damien Evans on Dec 06, 2006  (view change)
Labels: 
(None)

Introduction

Writing a DICOM file is easily done using standard Java OutputStream semantics. org.dcm4che2.io.DicomOutputStream extends java.io.FilterOutputStream to provide DICOM-specific write operations. For example, if we wanted to write the object that we read previously as a new file:

File f = new File("newFile.dcm");
FileOutputStream fos;
try {
    fos = new FileOutputStream(f);
}
catch (FileNotFoundException e) {
    e.printStackTrace();
    return;
}
BufferedOutputStream bos = new BufferedOutputStream(fos);
DicomOutputStream dos = new DicomOutputStream(bos);
try {
    dos.writeDicomFile(obj);
}
catch (IOException e) {
    e.printStackTrace();
    return;
}
finally {
    try {
        dos.close();
    }
    catch (IOException ignore) {
    }
}



This page has been viewed 3457 times.

Powered by a free Atlassian Confluence Open Source Project License granted to dcm4che. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators