1 2 24 25 26 27 28 29 package com.lutris.classloader; 30 31 import java.io.FileNotFoundException ; 34 import java.io.IOException ; 35 import java.io.InputStream ; 36 import java.net.MalformedURLException ; 37 import java.net.URL ; 38 import java.net.URLConnection ; 39 40 import com.lutris.logging.LogChannel; 41 42 54 public class RemoteDirResource extends Resource { 55 56 58 private URL url = null; 59 60 62 private RemoteDirResource(String name, ClassPathEntry location, 64 LogChannel loadLogChannel) 66 throws FileNotFoundException { 68 super(name, location, loadLogChannel); 70 72 URL locURL = location.getURL(); 74 if (locURL == null) { 75 throw new FileNotFoundException ( "The URL for location, " 76 + location + ", is null"); 77 } 78 79 try { 81 url = new URL (locURL.toString() + name); 82 } catch (MalformedURLException mue) { 83 throw new FileNotFoundException ("The URL can not be created from the name " 84 + name + ", and location " + locURL 85 + ": " +mue.getMessage()); 86 } 87 88 URLConnection connection; 90 try { 91 connection = url.openConnection(); 92 } catch (IOException ioe) { 93 throw new FileNotFoundException ("URL, " + url 94 + ", does not exist or can not be reached"); 95 } 96 size = connection.getContentLength(); 97 lastModifiedTime = connection.getLastModified(); 98 } 100 101 103 public InputStream getInputStream() throws IOException { 104 return url.openStream(); 105 } 106 107 114 public long getCurrentLastModifiedTime() { 115 return -1; } 117 } 118 | Popular Tags |