01: package org.jicengine.io;
02:
03: import java.io.*;
04: import java.net.URL;
05:
06: /**
07: * A resource that is read through an Url.
08: *
09: * <p>
10: * Copyright (C) 2004 Timo Laitinen
11: * </p>
12: * @author Timo Laitinen
13: * @created 2004-09-20
14: * @since JICE-0.10
15: * @version 1.0
16: */
17:
18: public class UrlResource extends AbstractResource implements
19: UrlReadable {
20:
21: private URL url;
22:
23: public UrlResource(URL url) {
24: super (url.toString());
25: this .url = url;
26: }
27:
28: public UrlResource(String url)
29: throws java.net.MalformedURLException {
30: this (new URL(url));
31: }
32:
33: public URL getUrl() {
34: return this .url;
35: }
36:
37: public InputStream getInputStream() throws java.io.IOException {
38: return getUrl().openStream();
39: }
40:
41: public Resource getResource(String relativePath) throws IOException {
42: return new UrlResource(new URL(getUrl(), relativePath));
43: }
44: }
|