is.close(); fos.close();
    private static void writeBitstreams(Context c, Item i, File destDir)            throws Exception    {        File outFile = new File(destDir, "contents");        if (outFile.createNewFile())        {            PrintWriter out = new PrintWriter(new FileWriter(outFile));            Bundle[] bundles = i.getBundles();            for (int j = 0; j < bundles.length; j++)            {                // bundles can have multiple bitstreams now...                Bitstream[] bitstreams = bundles[j].getBitstreams();                String bundleName = bundles[j].getName();                for (int k = 0; k < bitstreams.length; k++)                {                    Bitstream b = bitstreams[k];                    String myName = b.getName();                    String oldName = myName;                    int myPrefix = 1; // only used with name conflict                    InputStream is = b.retrieve();                    boolean isDone = false; // done when bitstream is finally                                            // written                    while (!isDone)                    {                        File fout = new File(destDir, myName);                        if (fout.createNewFile())                        {                            FileOutputStream fos = new FileOutputStream(fout);                            Utils.bufferedCopy(is, fos);                            // write the manifest file entry                            if (b.isRegisteredBitstream()) {                                out.println("-r -s " + b.getStoreNumber()                                 		+ " -f " + myName 										+ "\tbundle:" + bundleName);                            } else {                                out.println(myName + "\tbundle:" + bundleName);                            }                            isDone = true;                        }                        else                        {                            myName = myPrefix + "_" + oldName; // keep appending                                                               // numbers to the                                                               // filename until                                                               // unique                            myPrefix++;                        }                    }                }            }            // close the contents file            out.close();        }        else        {            throw new Exception("Cannot create contents in " + destDir);        }    }