Hi Nick,

Thanks for getting back to me. I am in fact working on MPXJ at the moment, I
help contribute to it as we use it for our product.

What we're trying to accomplish is to be able to take a project file, make
some modifications to it and then save it, all using the POIFSFileSystem. 

However, the problem below occurs if I merely open the Project with POIFS,
write it to another file with POIFS without any modifications and then try
to re-open the file using POIFS.

Also the file is a valid file (seems to happen with all files) and it can be
opened with POIFS and MS Project prior to it being written to another file.

Here is the code that causes the problem... is there something I should be
doing differently? I've tried a more manual read/write approach as well with
the same results...

      // Read the file
      FileInputStream is = new FileInputStream (input);
      POIFSFileSystem fs = new POIFSFileSystem (is);

      // Write the file
      FileOutputStream os = new FileOutputStream(output);                  
      fs.writeFilesystem(os);
      os.flush();
      os.close();
      is.close();

      // Read the file again
      is = new FileInputStream (output);
      fs = new POIFSFileSystem (is);

Strangely, the file size remains exactly the same and the new file can in
fact be opened using MS Project and if saved using MS Project it opens as
expected using POIFS.

Thanks for your help!

BR,
Jari Niskala
Get a FREE Microsoft Project Viewer at http://www.kadonk.com 

-----Original Message-----
From: Nick Burch [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 18, 2008 5:07 AM
To: POI Users List
Cc: 'Jari Niskala'
Subject: Re: Read->Modify->Write

On Sat, 16 Feb 2008, Jari Niskala wrote:
> My problem scenario occurs when I'm trying to read a MS Project file, then
> modify it and finally write its contents to another file using the
> POIFSFileSystem.
>
> However, even with just reading, then writing the contents I am getting 
> this exception:
> java.io.IOException: block[ 0 ] already removed

Looks like your file might be corrupt. You shouldn't be seeing an error 
like that with a valid file. I'd suggest opening it up in project, and 
doing a "save as" to force a full write, and see if that fixes it

Also, have you come across MPXJ [1]? It's an open source project for 
handling project files, which uses POI for the low level manipulation

Nick
[1] http://mpxj.sourceforge.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to