Shane McKee - 2008-11-02

I am trying to add a new image to a document originally created with Word.
Every time I try to add the image I get a NullPointerException for my OutputStream.
What am I doing wrong? Here is a snippet of my code. Thanks in advance for any help.

    public void InsertImages(String src, String contentType, Package pkg) {
        try {
            File image = new File(src);
            PackagePartName pkgPartName = PackagingURIHelper.createPartName("/word/media/abc.tiff");
            PackagePart imagePart = pkg.getPart(pkgPartName);               
            ZipInputStream is = new ZipInputStream(new FileInputStream(image));
            OutputStream os = imagePart.getOutputStream();
           
           

           
            byte[] buf = new byte[1024];
            int len;
            while((len = is.read(buf)) > 0) {
                imagePart.save(os);
            }
            is.close();
            os.close();