/**
  * @param o
  * @throws IOException
  * @throws DicomException
  */
 public void write(DicomOutputStream o) throws DicomException, IOException {
   // throw new DicomException("Internal error - unsupported operation, write of
   // OtherWordAttributeOnDisk");
   writeBase(o);
   if (valueLength > 0) {
     // System.err.println("OtherWordAttributeOnDisk.write(): start file = "+file);
     BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
     CopyStream.skipInsistently(in, byteOffset);
     if (bigEndian == o.isBigEndian()) {
       CopyStream.copy(in, o, valueLength);
     } else {
       CopyStream.copyByteSwapped(in, o, valueLength);
     }
     in.close();
   }
 }
Ejemplo n.º 2
0
 /**
  * Do something with the referenced DICOM file that has been encountered.
  *
  * <p>This method needs to be implemented in a sub-class to do anything useful. The default method
  * does nothing.
  *
  * <p>This method does not define any exceptions and hence must handle any errors locally.
  *
  * @param mediaFileName the fully qualified path name to a DICOM file
  */
 protected void doSomethingWithDicomFileOnMedia(String mediaFileName) {
   logLn("MediaImporter.doSomethingWithDicomFile(): " + mediaFileName);
   try {
     AttributeList list = new AttributeList();
     list.readOnlyMetaInformationHeader(mediaFileName);
     String outputFileName =
         Attribute.getSingleStringValueOrEmptyString(list, TagFromName.MediaStorageSOPInstanceUID);
     if (outputFileName.length() > 0) {
       CopyStream.copy(new File(mediaFileName), new File(outputPath, outputFileName));
     } else {
       throw new DicomException(
           "Cannot extract SOP Instance UID from \""
               + mediaFileName
               + "\" to create output file name - ignoring");
     }
   } catch (Exception e) {
     e.printStackTrace(System.err);
   }
 }