Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 21 22 27 28 package javax.activation; 29 30 import java.net.URL ; 31 import java.net.URLConnection ; 32 import java.io.InputStream ; 33 import java.io.OutputStream ; 34 import java.io.IOException ; 35 36 47 public class URLDataSource implements DataSource { 48 private URL url = null; 49 private URLConnection url_conn = null; 50 51 58 public URLDataSource(URL url) { 59 this.url = url; 60 } 61 62 73 public String getContentType() { 74 String type = null; 75 76 try { 77 if (url_conn == null) 78 url_conn = url.openConnection(); 79 } catch (IOException e) { } 80 81 if (url_conn != null) 82 type = url_conn.getContentType(); 83 84 if (type == null) 85 type = "application/octet-stream"; 86 87 return type; 88 } 89 90 96 public String getName() { 97 return url.getFile(); 98 } 99 100 106 public InputStream getInputStream() throws IOException { 107 return url.openStream(); 108 } 109 110 118 public OutputStream getOutputStream() throws IOException { 119 url_conn = url.openConnection(); 121 122 if (url_conn != null) { 123 url_conn.setDoOutput(true); 124 return url_conn.getOutputStream(); 125 } else 126 return null; 127 } 128 129 134 public URL getURL() { 135 return url; 136 } 137 } 138
| Popular Tags
|