Hello,

I'm about to patch my first bit of code and would like to run it by the list
first for comments and such.  Its not a big patch, but it my have a big
scope. 

I was running an example from the user guide that demonstrates WSDL2Java.
The command issues was:

"java org.apache.axis.wsdl.WSDL2Java AddressBook.wsdl"

I didn't have write access to the samples/addr directory so I got:

java.io.FileNotFoundException: AddressFetcher2/Address.java (No such file or
directory)

Really this isn't the full story.  AddressFetcher2 was not only missing, but
could not be created which is what caused it to be missing....

So I propose a patch to JavaWrite.getPrintWriter to make it the following:

    protected PrintWriter getPrintWriter(String filename) throws IOException
{
        System.out.println("filename with are trying to write " + filename);
    
        SecurityManager sm = new SecurityManager();
        try {
                sm.checkWrite(filename);
        }
        catch (SecurityException e) {
                System.out.println("The following exception has occured: " +
e + "\n It is likely that you do not have permission to write to the current
directory.");
                System.exit(0);
        }
        File file = new File(filename);
        File parent = new File(file.getParent());
        parent.mkdirs();
        return new PrintWriter(new FileWriter(file));
    } // getPrintWriter


My main questions are if this code should use the JCL instead of System.out,
and if this exception should be caught somewhere else.

Thanks,

Adhamh 


Reply via email to