All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.powerlibraries.io.builder.sources.URLSource Maven / Gradle / Ivy

Go to download

Power Libraries is a small project to collect some repeatedly needed or otherwise useful Java 8 classes in a collection of tiny libraries. IO Power is the first and really tiny library of the Power Libraries. It contains some simple helper method for opening Input- and Outputstreams. The main purpose of IO Power is to make opening streams, readers and writers less cluttered and simple to understand.

There is a newer version: 1.1.3
Show newest version
package com.github.powerlibraries.io.builder.sources;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

/**
 * This method is a source that wraps an {@link URL}.
 * @author Manuel Hegner
 *
 */
public class URLSource implements Source {

	private URL url;

	public URLSource(URL url) {
		this.url=url;
	}
	
	@Override
	public InputStream openStream() throws IOException {
		return url.openStream();
	}

	@Override
	public boolean hasName() {
		return true;
	}

	/**
	 * @return the result of {@link URL#toString}
	 */
	@Override
	public String getName() {
		return url.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy