Writing DICOM files

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

Unknown macro: {tracking-info}

zero

times.