001package org.unix4j.io;
002
003import java.io.IOException;
004import java.io.InputStream;
005import java.net.URL;
006
007/**
008 * Input device based on a {@link URL}.
009 */
010public class URLInput extends StreamInput {
011
012        private final String urlInfo;
013
014        public URLInput(URL url) {
015                super(openStream(url));
016                this.urlInfo = url.toExternalForm();
017        }
018
019        private static InputStream openStream(URL url) {
020                try {
021                        return url.openStream();
022                } catch (IOException e) {
023                        throw new RuntimeException(e);
024                }
025        }
026
027        @Override
028        public String toString() {
029                return urlInfo;
030        }
031}