Functionality: Copy File
Clone type: Type-3 (WT3/4)
Is clone: TRUE

Function 1:
public void convert (File src, File dest) throws IOException {
    InputStream in = new BufferedInputStream (new FileInputStream (src));
    DcmParser p = pfact.newDcmParser (in);
    Dataset ds = fact.newDataset ();
    p.setDcmHandler (ds.getDcmHandler ());
    try {
        FileFormat format = p.detectFileFormat ();
        if (format != FileFormat.ACRNEMA_STREAM) {
            System.out.println ("\n" + src + ": not an ACRNEMA stream!");
            return;
        }
        p.parseDcmFile (format, Tags.PixelData);
        if (ds.contains (Tags.StudyInstanceUID) || ds.contains (Tags.SeriesInstanceUID) || ds.contains (Tags.SOPInstanceUID) || ds.contains (Tags.SOPClassUID)) {
            System.out.println ("\n" + src + ": contains UIDs!" + " => probable already DICOM - do not convert");
            return;
        }
        boolean hasPixelData = p.getReadTag () == Tags.PixelData;
        boolean inflate = hasPixelData && ds.getInt (Tags.BitsAllocated, 0) == 12;
        int pxlen = p.getReadLength ();
        if (hasPixelData) {
            if (inflate) {
                ds.putUS (Tags.BitsAllocated, 16);
                pxlen = pxlen * 4 / 3;
            }
            if (pxlen != (ds.getInt (Tags.BitsAllocated, 0)>>> 3) * ds.getInt (Tags.Rows, 0) * ds.getInt (Tags.Columns, 0) * ds.getInt (Tags.NumberOfFrames, 1) * ds.getInt (Tags.NumberOfSamples, 1)) {
                System.out.println ("\n" + src + ": mismatch pixel data length!" + " => do not convert");
                return;
            }
        }
        ds.putUI (Tags.StudyInstanceUID, uid (studyUID));
        ds.putUI (Tags.SeriesInstanceUID, uid (seriesUID));
        ds.putUI (Tags.SOPInstanceUID, uid (instUID));
        ds.putUI (Tags.SOPClassUID, classUID);
        if (! ds.contains (Tags.NumberOfSamples)) {
            ds.putUS (Tags.NumberOfSamples, 1);
        }
        if (! ds.contains (Tags.PhotometricInterpretation)) {
            ds.putCS (Tags.PhotometricInterpretation, "MONOCHROME2");
        }
        if (fmi) {
            ds.setFileMetaInfo (fact.newFileMetaInfo (ds, UIDs.ImplicitVRLittleEndian));
        }
        OutputStream out = new BufferedOutputStream (new FileOutputStream (dest));
        try {
        } finally {
            ds.writeFile (out, encodeParam ());
            if (hasPixelData) {
                if (! skipGroupLen) {
                    out.write (PXDATA_GROUPLEN);
                    int grlen = pxlen + 8;
                    out.write ((byte) grlen);
                    out.write ((byte) (grlen>> 8));
                    out.write ((byte) (grlen>> 16));
                    out.write ((byte) (grlen>> 24));
                }
                out.write (PXDATA_TAG);
                out.write ((byte) pxlen);
                out.write ((byte) (pxlen>> 8));
                out.write ((byte) (pxlen>> 16));
                out.write ((byte) (pxlen>> 24));
            }
            if (inflate) {
                int b2, b3;
                for (; pxlen > 0; pxlen -= 3) {
                    out.write (in.read ());
                    b2 = in.read ();
                    b3 = in.read ();
                    out.write (b2 & 0x0f);
                    out.write (b2>> 4 | ((b3 & 0x0f) << 4));
                    out.write (b3>> 4);
                }
            } else {
                for (; pxlen > 0; -- pxlen) {
                    out.write (in.read ());
                }
            }
            out.close ();
        }
        System.out.print ('.');
    } finally {
        in.close ();
    }
}

Function 2:
public BufferedWriter createOutputStream (String inFile, String outFile) throws IOException {
    int k_blockSize = 1024;
    int byteCount;
    char [] buf = new char [k_blockSize];
    File ofp = new File (outFile);
    ZipOutputStream zos = new ZipOutputStream (new FileOutputStream (ofp));
    zos.setMethod (ZipOutputStream.DEFLATED);
    OutputStreamWriter osw = new OutputStreamWriter (zos, "ISO-8859-1");
    BufferedWriter bw = new BufferedWriter (osw);
    ZipEntry zot = null;
    File ifp = new File (inFile);
    ZipInputStream zis = new ZipInputStream (new FileInputStream (ifp));
    InputStreamReader isr = new InputStreamReader (zis, "ISO-8859-1");
    BufferedReader br = new BufferedReader (isr);
    ZipEntry zit = null;
    while ((zit = zis.getNextEntry ()) != null) {
        if (zit.getName ().equals ("content.xml")) {
            continue;
        }
        zot = new ZipEntry (zit.getName ());
        zos.putNextEntry (zot);
        while ((byteCount = br.read (buf, 0, k_blockSize)) >= 0) bw.write (buf, 0, byteCount);

        bw.flush ();
        zos.closeEntry ();
    }
    zos.putNextEntry (new ZipEntry ("content.xml"));
    bw.flush ();
    osw = new OutputStreamWriter (zos, "UTF8");
    bw = new BufferedWriter (osw);
    return bw;
}