Load a file from an URL.

@param fileURL
Property file URL - Cannot be <code>null</code>.

@return Properties.
964386
public static Properties loadProperties(final URL fileURL) {
        checkNotNull("fileURL", fileURL);
        final Properties props = new Properties();
        try (final InputStream inStream = fileURL.openStream()) {
            props.load(inStream);
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
        return props;
    }
114000
@Nullable
  public static Properties loadPropertiesFromFile(String filePath) {
    try (FileInputStream fileInputStream = new FileInputStream(filePath)) {
      return loadProperties(fileInputStream);
    } catch (FileNotFoundException e) {
      return null;
    } catch (IOException e) {
      LOG.warn("Failed to close property input stream from {}: {}", filePath, e.toString());
      return null;
    }
  }
1323463
protected void loadProperties(String filename) {
		ClassLoader thclassLoader = Thread.currentThread().getContextClassLoader();
		if (thclassLoader != null){
			URL url = thclassLoader.getResource(filename);
			if (url != null){
				try {
					this.setXMLProperties(url.openStream(), null);
				} catch (Exception e) {
					// do nothing
				} 
			}
		}
	}
49111
public static byte[] loadBytes(URL url) {
        byte[] bytes = null;
        try {
            bytes = loadBytes(url.openStream());
        } catch (IOException ex) {
            // ex.printStackTrace();
        }
        return bytes;
    }
387423
private function load($url) {
		if (!file_exists($url)) {
			throw new \n2n\log4php\LoggerException("File [$url] does not exist.");
		}
		
		$properties = \n2n\io\IoUtils::parseIniFile($url, true);
		if ($properties === false) {
			$error = error_get_last();
			throw new \n2n\log4php\LoggerException("Error parsing configuration file: {$error['message']}");
		}
		
		return $properties;
	}
513168
@Override
	public URL getURL() throws IOException {
		URL url = resolveURL();
		if (url == null) {
			throw new FileNotFoundException(getDescription() + " cannot be resolved to URL because it does not exist");
		}
		return url;
	}
48886
protected void load()
    {
        properties = new Properties();

        String filename = getFilename();
        
        try
        {
            URL url = ClassHelper.getResource(filename);

            if (url == null)
            {
                url = (new File(filename)).toURL();
            }

            logger.info("Loading OJB's properties: " + url);

            URLConnection conn = url.openConnection();
            conn.setUseCaches(false);
            conn.connect();
            InputStream strIn = conn.getInputStream();
            properties.load(strIn);
            strIn.close();
        }
        catch (FileNotFoundException ex)
        {
            // [tomdz] If the filename is explicitly reset (null or empty string) then we'll
            //         output an info message because the user did this on purpose
            //         Otherwise, we'll output a warning
            if ((filename == null) || (filename.length() == 0))
            {
                logger.info("Starting OJB without a properties file. OJB is using default settings instead.");
            }
            else
            {
                logger.warn("Could not load properties file '"+filename+"'. Using default settings!", ex);
            }
            // [tomdz] There seems to be no use of this setting ?
            //properties.put("valid", "false");
        }
        catch (Exception ex)
        {
            throw new MetadataException("An error happend while loading the properties file '"+filename+"'", ex);
        }
    }
419175
def loadFromURL(self, url):
        """"""
        if isfile(url) is True:
            file = open(url, 'r')
        else:
            file = urlopen(url)

        try:     
            result = self.loadDocument(file)
        except Exception, ex:
            file.close()
            raise ParseError(('Failed to load document %s' %url,) + ex.args)
        else:
            file.close()
        return result
562110
public static URL url(final String url) {
        if (url == null) {
            return null;
        }
        try {
            if (url.startsWith("classpath:")) {
                return new URL(null, url, new ClasspathURLStreamHandler());
            }
            return new URL(url);
        } catch (final MalformedURLException ex) {
            throw new IllegalArgumentException("Invalid URL: " + url, ex);
        }
    }
685459
public static File getOrCreateFile(String url, boolean createIfNotFound) throws IOException {
        File file = null;
        if (url.contains(ResourceUtils.CLASSPATH_URL_PREFIX)) {
            url = url.replaceAll(ResourceUtils.CLASSPATH_URL_PREFIX, "");
            if (url.startsWith("/")) {
                url = url.substring(1);
            }
            URL resource = SenBotContext.class.getClassLoader().getResource("");
            if (resource == null) {
                throw new IOException("creating a new folder on the classpath is not allowed");
            } else {
                file = new File(resource.getFile() + "/" + url);
            }
        } else {
            file = new File(url);
        }
        if (createIfNotFound && !file.exists()) {
            file.mkdirs();
        }
        return file;
    }
84887
public ImageHelper load(ImageView v, String url) {
        return load(v, url, null);
    }
797563
public static Properties fetchProperties(final File propFile) {
        final Properties properties = new Properties();
        try {
            FileInputStream fis = new FileInputStream(propFile);
            try {
                properties.load(fis);
            } finally {
                if(null!=fis){
                    fis.close();
                }
            }
        } catch (IOException e) {
            throw new PropertyLookupException("failed loading properties from file: " + propFile, e);
        }
        return properties;
    }
50662
private String loadSource(String sourceUrl) {
        String source = null;
        int hash = sourceUrl.indexOf('#');
        if (hash >= 0) {
            sourceUrl = sourceUrl.substring(0, hash);
        }
        try {
            InputStream is;
          openStream:
            {
                if (sourceUrl.indexOf(':') < 0) {
                    // Can be a file name
                    try {
                        if (sourceUrl.startsWith("~/")) {
                            String home = SecurityUtilities.getSystemProperty("user.home");
                            if (home != null) {
                                String pathFromHome = sourceUrl.substring(2);
                                File f = new File(new File(home), pathFromHome);
                                if (f.exists()) {
                                    is = new FileInputStream(f);
                                    break openStream;
                                }
                            }
                        }
                        File f = new File(sourceUrl);
                        if (f.exists()) {
                            is = new FileInputStream(f);
                            break openStream;
                        }
                    } catch (SecurityException ex) { }
                    // No existing file, assume missed http://
                    if (sourceUrl.startsWith("//")) {
                        sourceUrl = "http:" + sourceUrl;
                    } else if (sourceUrl.startsWith("/")) {
                        sourceUrl = "http://127.0.0.1" + sourceUrl;
                    } else {
                        sourceUrl = "http://" + sourceUrl;
                    }
                }

                is = (new URL(sourceUrl)).openStream();
            }

            try {
                source = Kit.readReader(new InputStreamReader(is));
            } finally {
                is.close();
            }
        } catch (IOException ex) {
            System.err.println
                ("Failed to load source from "+sourceUrl+": "+ ex);
        }
        return source;
    }
459820
private static InputStream inputStreamFromFile(URL resourceUrl)
      throws IOException, URISyntaxException {
    File resourceFile = new File(resourceUrl.toURI());
    return new FileInputStream(resourceFile);
  }
1203441
public static Properties loadFile(File file) throws IOException {
		InputStream input = new FileInputStream(file);
		Properties prop = null;
		try {
			prop = load(input);
		} finally {
			IOUtils.close(input);
		}
		return prop;
	}
1078709
private static Properties loadProperties(String propertiesFile) {
    Properties properties = new Properties();
    try (InputStream is = new FileInputStream(propertiesFile)) {
      properties.load(is);
    } catch (IOException e) {
      throw new RuntimeException("failed to load properties", e);
    }
    return properties;
  }
949267
public static Properties load(File file) throws IOException {
        if (file.isFile()) {
            FileInputStream fis = null;
            try {
                Properties headers = new Properties();
                fis = new FileInputStream(file);
                headers.load(fis);
                return headers;
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }
        return new Properties();
    }