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 17 18 19 21 40 41 import java.io.*; import java.net.*; import java.util.*; 45 46 58 public class ExtractorURLConnection extends URLConnection { 59 60 protected InputStream is; 62 66 public ExtractorURLConnection( URL u ) 67 { 68 super(u); 69 } 70 71 90 93 public String getContentType() 94 { 95 String file = getURL().getFile(); 96 String ct = null; 97 98 if ( file.endsWith(".jpg") || file.endsWith(".jpeg") || 99 file.endsWith(".jpe") || file.endsWith(".jfif") ) 100 ct = "image/jpeg"; 101 else if ( file.endsWith(".gif") ) 102 ct = "image/gif"; 103 else if ( file.endsWith(".htm") || file.endsWith(".html") ) 104 ct = "text/html"; 105 else if ( file.endsWith(".rtf") || file.endsWith(".rtx" ) ) 106 ct = "application/rtf"; 107 else if ( file.endsWith(".eps") || file.endsWith(".ps" ) ) 108 ct = "application/postscript"; 109 else if ( file.endsWith(".snd") || file.endsWith(".au") ) 110 ct = "audio/basic"; 111 else if ( file.endsWith(".aifc") || file.endsWith(".aif") || 112 file.endsWith(".aiff") ) 113 ct = "audio/x-aiff"; 114 else if ( file.endsWith(".wav") || file.endsWith(".wave") ) 115 ct = "audio/x-wav"; 116 else if ( file.endsWith(".gz") || file.endsWith(".tgz") ) 117 ct = "audio/x-gtar"; 118 else if ( file.endsWith(".zip") ) 119 ct = "application/zip"; 120 else if ( file.endsWith(".tar") ) 121 ct = "application/x-tar"; 122 else if ( file.endsWith(".cpio") ) 123 ct = "application/x-cpio"; 124 else 125 ct = "text/plain"; 126 127 System.out.println("\n++++++++++ ExtractorURLConnection.getContentType() type = "+ct+"\n"); 128 return (ct); 129 } 130 131 140 public synchronized InputStream getInputStream() 141 throws IOException 142 { 143 System.out.println( "ExtractorURLOpenConnection.getInputStream() connected:"+connected); 144 if (!connected) { 145 connect(); 146 } 147 148 return (is); 149 } 150 151 160 public synchronized void connect() 161 throws IOException 162 { 163 System.out.println( "ExtractorURLOpenConnection.connect()"); 164 if (!connected) { 165 is = Extractor.getCachedResourceAsInputStream( url ); 166 connected = true; 167 } 168 } 169 } 170 171
| Popular Tags
|