Thanks for the bug report - the Properties class wasn't my work, but
I've included the Classpath mailing list in the recipients of this
message, so whoever wrote it can comment on whether this is a legitimate
bug, and fix it for you.

Thanks for trying out GNU Classpath! :)

Stuart.

Matt Mucklo wrote:
> 
> I've found a possible bug in java.util.Properties.save().
> 
> It seems that you create a PrintWriter object as the
> means to write out to the stream that's passed in.
> 
> Unfortunately, it seems that the PrintWriter object is
> buffered.  Since you don't close it after returning, the
> output has a chance of never getting written out to
> the underlying stream.
> 
> A simple solution would be to do a PrintWriter.flush()
> call before exiting the method.
> 
> // Test case
> 
> import java.util.Properties;
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.io.FileOutputStream;
> 
> public class TestSaveProperties {
> 
>     public static void main(String[] args) {
>  if( args.length != 2 ) {
>      System.err.println("usage: TestSaveProperties <inputFile>
> <outputFile>");
>      System.exit(1);
>  }
> 
>  try {
>      Properties properties = new Properties();
>      FileInputStream fis   = new FileInputStream(args[0]);
>      properties.load(fis);
>      fis.close();
>      FileOutputStream fos  = new FileOutputStream(args[1]);
>      properties.save(fos, "Test Save");
>      fos.close();
>  }
>  catch( Exception e ) {
>      e.printStackTrace();
>  }
>     }
> }

Reply via email to