Code example for URL

Methods: getFile

0
    } 
    
    protected final File getTestClassDirectory() throws IOException {
        URL url = this.getClass().getResource(".");  // Deliberately gets the package URL of the subclass
        if (url == null) throw new IOException("Couldn't get resource URL for \".\"");
        return new File(url.getFile());
    } 
 
    protected String loadFile(File f) throws FileNotFoundException, IOException {
        return loadFile(f, getDefaultCharset());
    } 
     
    protected String loadFile(File f, String charset) throws FileNotFoundException, IOException {
        return loadString(new FileInputStream(f), charset);
    } 
 
    protected String loadResource(String resourceName) throws FileNotFoundException, IOException {
        return loadResource(resourceName, getDefaultCharset());
    } 
     
    protected String loadResource(String resourceName, String charset) throws FileNotFoundException, IOException {