home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / activation / URLDataSource.class (.txt) < prev   
Encoding:
Java Class File  |  2006-11-29  |  1005 b   |  60 lines

  1. package javax.activation;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.OutputStream;
  6. import java.net.URL;
  7. import java.net.URLConnection;
  8.  
  9. public class URLDataSource implements DataSource {
  10.    private URL url = null;
  11.    private URLConnection url_conn = null;
  12.  
  13.    public URLDataSource(URL var1) {
  14.       this.url = var1;
  15.    }
  16.  
  17.    public String getContentType() {
  18.       String var1 = null;
  19.  
  20.       try {
  21.          if (this.url_conn == null) {
  22.             this.url_conn = this.url.openConnection();
  23.          }
  24.       } catch (IOException var3) {
  25.       }
  26.  
  27.       if (this.url_conn != null) {
  28.          var1 = this.url_conn.getContentType();
  29.       }
  30.  
  31.       if (var1 == null) {
  32.          var1 = "application/octet-stream";
  33.       }
  34.  
  35.       return var1;
  36.    }
  37.  
  38.    public String getName() {
  39.       return this.url.getFile();
  40.    }
  41.  
  42.    public InputStream getInputStream() throws IOException {
  43.       return this.url.openStream();
  44.    }
  45.  
  46.    public OutputStream getOutputStream() throws IOException {
  47.       this.url_conn = this.url.openConnection();
  48.       if (this.url_conn != null) {
  49.          this.url_conn.setDoOutput(true);
  50.          return this.url_conn.getOutputStream();
  51.       } else {
  52.          return null;
  53.       }
  54.    }
  55.  
  56.    public URL getURL() {
  57.       return this.url;
  58.    }
  59. }
  60.