Code example for MalformedURLException

0
        File file = new File(orig.getPath());
 
        // If it is a file, except 
        if (file.isFile()) {
            // TRANSLATOR: Error condition: A directory was expected, but a file was found. {0} is a placeholder for the file. 
            throw new MalformedURLException(JSMsg.gettext("The URL {0} is a file.", orig));
        } 
 
        // Is it already a directory ? 
        if (!file.isDirectory()) {
            // Create the directory and make sure it worked. 
            if (!file.mkdirs()) {
                // TRANSLATOR: Error condition: A directory could not be created. {0} is a placeholder for the directory 
                throw new MalformedURLException(JSMsg.gettext("The URL {0} could not be created as a directory.", orig));
            } 
        } 
    } 
 
    /** 
     * If the file does not exist, create it. Note this currently only works 
     * with file: type URIs