/** * Loads the drawing. By convention this method is invoked on a worker thread. * * @param progress A ProgressIndicator to inform the user about the progress of the operation. * @return The Drawing that was loaded. */ protected Drawing loadDrawing(ProgressIndicator progress) throws IOException { Drawing drawing = createDrawing(); if (getParameter("datafile") != null) { URL url = new URL(getDocumentBase(), getParameter("datafile")); URLConnection uc = url.openConnection(); // Disable caching. This ensures that we always request the // newest version of the drawing from the server. // (Note: The server still needs to set the proper HTTP caching // properties to prevent proxies from caching the drawing). if (uc instanceof HttpURLConnection) { ((HttpURLConnection) uc).setUseCaches(false); } // Read the data into a buffer int contentLength = uc.getContentLength(); InputStream in = uc.getInputStream(); try { if (contentLength != -1) { in = new BoundedRangeInputStream(in); ((BoundedRangeInputStream) in).setMaximum(contentLength + 1); progress.setProgressModel((BoundedRangeModel) in); progress.setIndeterminate(false); } BufferedInputStream bin = new BufferedInputStream(in); bin.mark(512); // Read the data using all supported input formats // until we succeed IOException formatException = null; for (InputFormat format : drawing.getInputFormats()) { try { bin.reset(); } catch (IOException e) { uc = url.openConnection(); in = uc.getInputStream(); in = new BoundedRangeInputStream(in); ((BoundedRangeInputStream) in).setMaximum(contentLength + 1); progress.setProgressModel((BoundedRangeModel) in); bin = new BufferedInputStream(in); bin.mark(512); } try { bin.reset(); format.read(bin, drawing, true); formatException = null; break; } catch (IOException e) { formatException = e; } } if (formatException != null) { throw formatException; } } finally { in.close(); } } return drawing; }
/** * Loads the propertis from the file given the URL * * @param urlString URL of the file to be used for loading he properties * @param p Properties */ private static void loadPropertyFile(Properties p, String urlString) { if (urlString == null) { spec.harness.Context.out.println("Null urlString"); return; } try { URL url = new URL(urlString); boolean ok = true; int ind = urlString.indexOf("http:", 0); // spec.harness.Context.out.println( urlString + "=" + ind); if (ind == 0) { ok = spec.io.FileInputStream.IsURLOk(url); } if (ok) { InputStream str = url.openStream(); if (str == null) { spec.harness.Context.out.println("InputStream in loadPropertyFile is null"); } else { p.load(new BufferedInputStream(str)); } } else { spec.harness.Context.out.println("Could not open URL " + urlString); } } catch (Exception e) { spec.harness.Context.out.println("Error loading property file " + urlString + " : " + e); // e.printStackTrace( spec.harness.Context.out ); } }
public boolean shutdown(int port, boolean ssl) { try { String protocol = "http" + (ssl ? "s" : ""); URL url = new URL(protocol, "127.0.0.1", port, "shutdown"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("servicemanager", "shutdown"); conn.connect(); StringBuffer sb = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); int n; char[] cbuf = new char[1024]; while ((n = br.read(cbuf, 0, cbuf.length)) != -1) sb.append(cbuf, 0, n); br.close(); String message = sb.toString().replace("<br>", "\n"); if (message.contains("Goodbye")) { cp.appendln("Shutting down the server:"); String[] lines = message.split("\n"); for (String line : lines) { cp.append("..."); cp.appendln(line); } return true; } } catch (Exception ex) { } cp.appendln("Unable to shutdown CTP"); return false; }
/** * Gets the absolute path. * * @return the absolute path */ public String getAbsolutePath() { if (getFile() != null) { try { return XML.forwardSlash(getFile().getCanonicalPath()); } catch (IOException ex) { ex.printStackTrace(); } return getFile().getAbsolutePath(); } if (getURL() != null) { URL url = getURL(); String path = url.getPath(); // remove file protocol, if any if (path.startsWith("file:")) { // $NON-NLS-1$ path = path.substring(5); } // remove leading slash if drive is specified if (path.startsWith("/") && path.indexOf(":") > -1) { // $NON-NLS-1$ //$NON-NLS-2$ path = path.substring(1); } // replace "%20" with space int i = path.indexOf("%20"); // $NON-NLS-1$ while (i > -1) { String s = path.substring(0, i); path = s + " " + path.substring(i + 3); // $NON-NLS-1$ i = path.indexOf("%20"); // $NON-NLS-1$ } return path; } return null; }
public void init() { is_master = false; dyn_usr = 0; dyn_view = 0; id = (int) System.currentTimeMillis(); ClientApplet.client_applet = this; appletContext = getAppletContext(); hostsrv = getParameter("HOSTSRV"); String http_portString = getParameter("HTTP_PORT"); if (http_portString != null) { try { Integer port = Integer.valueOf(http_portString); http_port = port.intValue(); } catch (NumberFormatException e) { http_port = 50000; } } URL applet_url = this.getCodeBase(); String host = applet_url.getHost(); if (host != null) hostsrv = host; int port = applet_url.getPort(); if (port > 0) http_port = port; user_interface = new UserInterface(); user_interface.init(); }
/** * ** Gets the 'port' specification in the URI ** @return The 'port' specification in the URL, or * -1 if not port is specified */ public int getPort() { try { URL url = new URL(this.getURI()); return url.getPort(); } catch (MalformedURLException mue) { return -1; } }
/** * ** Gets the 'file' specification in the URI ** @return The 'file' specification in the URL, or * null if unable to determine file */ public String getFile() { try { URL url = new URL(this.getURI()); return url.getFile(); } catch (MalformedURLException mue) { return null; } }
static void openURL( JopSession session, String name, boolean newFrame, String frameName, String bookmark) { System.out.println("openURL " + name); Object root = session.getRoot(); // Replace any URL symbol name = replaceUrlSymbol(session, name); try { String url_str = null; if (name.substring(0, 5).equals("http:")) { url_str = name; if (url_str.lastIndexOf(".html") == -1 && url_str.lastIndexOf(".shtml") == -1 && url_str.lastIndexOf(".htm") == -1 && url_str.lastIndexOf(".pdf") == -1) url_str = url_str + ".html"; } else if (name.startsWith("$pwr_doc/")) { URL current = ((JApplet) root).getDocumentBase(); String current_str = current.toString(); int idx1 = current_str.indexOf('/'); if (idx1 != -1 && current_str.length() > idx1 + 1) { idx1 = current_str.indexOf('/', idx1 + 1); if (idx1 != -1 && current_str.length() > idx1 + 1) { idx1 = current_str.indexOf('/', idx1 + 1); if (idx1 != -1 && current_str.length() > idx1 + 1) { url_str = current_str.substring(0, idx1 + 1) + "pwr_doc/" + name.substring(9); if (url_str.lastIndexOf(".html") == -1 && url_str.lastIndexOf(".shtml") == -1 && url_str.lastIndexOf(".htm") == -1 && url_str.lastIndexOf(".pdf") == -1) url_str = url_str + ".html"; } } } } else { URL current = ((JApplet) root).getCodeBase(); String current_str = current.toString(); int idx1 = current_str.lastIndexOf('/'); int idx2 = current_str.lastIndexOf(':'); int idx = idx1; if (idx2 > idx) idx = idx2; String path = current_str.substring(0, idx + 1); if (name.lastIndexOf(".html") == -1 && name.lastIndexOf(".shtml") == -1 && name.lastIndexOf(".htm") == -1 && name.lastIndexOf(".pdf") == -1) url_str = new String(path + name + ".html"); else url_str = new String(path + name); if (bookmark != null) url_str += "#" + bookmark; } System.out.println("Opening URL: " + url_str); URL url = new URL(url_str); AppletContext appCtx = ((JApplet) root).getAppletContext(); if (newFrame) appCtx.showDocument(url, "_blank"); else if (frameName != null) appCtx.showDocument(url, frameName); else appCtx.showDocument(url, "_self"); } catch (MalformedURLException e) { System.out.println("MalformedURL : " + name); } }
@Override public InputSource resolveEntity(String publicId, String systemId) { if (systemId != null && systemId.endsWith("dtd")) { URL url = FileFuncs.getResource(RuntimeProperties.PACKAGE_DTD, true); if (url != null) { return new InputSource(url.toString()); } // if unable to find dtd in local fs, try getting it from web return new InputSource(RuntimeProperties.SCHEMA_LOC + RuntimeProperties.PACKAGE_DTD); } return null; }
private void readFromStorableInput(String filename) { try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); StorableInput input = new StorableInput(stream); fDrawing.release(); fDrawing = (Drawing) input.readStorable(); view().setDrawing(fDrawing); } catch (IOException e) { initDrawing(); showStatus("Error:" + e); } }
/** * Enumerates the resouces in a give package name. This works even if the resources are loaded * from a jar file! * * <p>Adapted from code by mikewse on the java.sun.com message boards. * http://forum.java.sun.com/thread.jsp?forum=22&thread=30984 * * @param packageName The package to enumerate * @return A Set of Strings for each resouce in the package. */ public static Set getResoucesInPackage(String packageName) throws IOException { String localPackageName; if (packageName.endsWith("/")) { localPackageName = packageName; } else { localPackageName = packageName + '/'; } Enumeration dirEnum = ClassLoader.getSystemResources(localPackageName); Set names = new HashSet(); // Loop CLASSPATH directories while (dirEnum.hasMoreElements()) { URL resUrl = (URL) dirEnum.nextElement(); // Pointing to filesystem directory if (resUrl.getProtocol().equals("file")) { File dir = new File(resUrl.getFile()); File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) continue; names.add(localPackageName + file.getName()); } } // Pointing to Jar file } else if (resUrl.getProtocol().equals("jar")) { JarURLConnection jconn = (JarURLConnection) resUrl.openConnection(); JarFile jfile = jconn.getJarFile(); Enumeration entryEnum = jfile.entries(); while (entryEnum.hasMoreElements()) { JarEntry entry = (JarEntry) entryEnum.nextElement(); String entryName = entry.getName(); // Exclude our own directory if (entryName.equals(localPackageName)) continue; String parentDirName = entryName.substring(0, entryName.lastIndexOf('/') + 1); if (!parentDirName.equals(localPackageName)) continue; names.add(entryName); } } else { // Invalid classpath entry } } return names; }
public AppFrame() { super(); GlobalData.oFrame = this; this.setSize(this.width, this.height); this.toolkit = Toolkit.getDefaultToolkit(); Dimension w = toolkit.getScreenSize(); int fx = (int) w.getWidth(); int fy = (int) w.getHeight(); int wx = (fx - this.width) / 2; int wy = (fy - this.getHeight()) / 2; setLocation(wx, wy); this.tracker = new MediaTracker(this); String sHost = ""; try { localAddr = InetAddress.getLocalHost(); if (localAddr.isLoopbackAddress()) { localAddr = LinuxInetAddress.getLocalHost(); } sHost = localAddr.getHostAddress(); } catch (UnknownHostException ex) { sHost = "你的IP地址错误"; } // this.textLines[0] = "服务器正在运行."; this.textLines[1] = ""; this.textLines[2] = "你的IP地址: " + sHost; this.textLines[3] = ""; this.textLines[4] = "请打开你的手机客户端"; this.textLines[5] = ""; this.textLines[6] = "输入屏幕上显示的IP地址."; // try { URL fileURL = this.getClass().getProtectionDomain().getCodeSource().getLocation(); String sBase = fileURL.toString(); if ("jar".equals(sBase.substring(sBase.length() - 3, sBase.length()))) { jar = new JarFile(new File(fileURL.toURI())); } else { basePath = System.getProperty("user.dir") + "\\res\\"; } } catch (Exception ex) { this.textLines[1] = "exception: " + ex.toString(); } }
private URL verifyUrl(String url) { if (!url.toLowerCase().startsWith("http://")) return null; URL verifiedUrl = null; try { verifiedUrl = new URL(url); } catch (Exception e) { return null; } if (verifiedUrl.getFile().length() < 2) return null; return verifiedUrl; }
private void readFromObjectInput(String filename) { try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); ObjectInput input = new ObjectInputStream(stream); fDrawing.release(); fDrawing = (Drawing) input.readObject(); view().setDrawing(fDrawing); } catch (IOException e) { initDrawing(); showStatus("Error: " + e); } catch (ClassNotFoundException e) { initDrawing(); showStatus("Class not found: " + e); } }
/** * Loads a font based on URL Path * * @param String filePath * @param float fontSize * @param FontStyle fontStyle * @throws FontFormatException * @throws IOException */ public INFont(URL filePath, float fontSize, FontStyle fontStyle) throws FontFormatException, IOException { File fontFile = new File(filePath.toString()); this.loadedFont = Font.createFont(Font.TRUETYPE_FONT, fontFile); this.loadedFont = this.loadedFont.deriveFont(fontSize); this.style = fontStyle; this.size = fontSize; switch (fontStyle) { case BOLD: this.loadedFont = this.loadedFont.deriveFont(Font.BOLD); break; case ITALIC: this.loadedFont = this.loadedFont.deriveFont(Font.ITALIC); break; case PLAIN: this.loadedFont = this.loadedFont.deriveFont(Font.PLAIN); break; case BOLDANDITALIC: this.loadedFont = this.loadedFont.deriveFont(Font.BOLD + Font.ITALIC); break; } }
/** * Reads GIF file from specified file/URL source (URL assumed if name contains ":/" or "file:") * * @param name String containing source * @return read status code (0 = no errors) */ public int read(String name) { status = STATUS_OK; try { name = name.trim().toLowerCase(); if ((name.indexOf("file:") >= 0) || (name.indexOf(":/") > 0)) { URL url = new URL(name); in = new BufferedInputStream(url.openStream()); } else { in = new BufferedInputStream(new FileInputStream(name)); } status = read(in); } catch (IOException e) { status = STATUS_OPEN_ERROR; } return status; }
public void openLink(String link) { if (WWUtil.isEmpty(link)) return; try { try { // See if the link is a URL, and invoke the browser if it is URL url = new URL(link.replace(" ", "%20")); Desktop.getDesktop().browse(url.toURI()); return; } catch (MalformedURLException ignored) { // just means that the link is not a URL } // It's not a URL, so see if it's a file and invoke the desktop to open it if it is. File file = new File(link); if (file.exists()) { Desktop.getDesktop().open(new File(link)); return; } String message = "Cannot open resource. It's not a valid file or URL."; Util.getLogger().log(Level.SEVERE, message); this.showErrorDialog(null, "No Reconocido V\u00ednculo", message); } catch (UnsupportedOperationException e) { String message = "Unable to open resource.\n" + link + (e.getMessage() != null ? "\n" + e.getMessage() : ""); Util.getLogger().log(Level.SEVERE, message, e); this.showErrorDialog(e, "Error Opening Resource", message); } catch (IOException e) { String message = "I/O error while opening resource.\n" + link + (e.getMessage() != null ? ".\n" + e.getMessage() : ""); Util.getLogger().log(Level.SEVERE, message, e); this.showErrorDialog(e, "I/O Error", message); } catch (Exception e) { String message = "Error attempting to open resource.\n" + link + (e.getMessage() != null ? "\n" + e.getMessage() : ""); Util.getLogger().log(Level.SEVERE, message); this.showMessageDialog(message, "Error Opening Resource", JOptionPane.ERROR_MESSAGE); } }
/** Remove data component data JAR from cache */ public static void removeInstallerComponent() { DownloadService downloadService = Config.getDownloadService(); if (downloadService != null) { String component = Config.getInstallerLocation(); String version = Config.getInstallerVersion(); try { URL codebase = Config.getBasicService().getCodeBase(); URL url = new URL(codebase, component); component = url.toString(); Config.trace("Removing: " + component + "/" + version); downloadService.removeResource(url, version); } catch (IOException ioe) { Config.trace("Unable to remove " + component + "/" + version); } } else { Config.trace("No download service found"); } }
private void downloadImage(final MercatorTextureTile tile, String mimeType) throws Exception { // System.out.println(tile.getPath()); final URL resourceURL = tile.getResourceURL(mimeType); Retriever retriever; String protocol = resourceURL.getProtocol(); if ("http".equalsIgnoreCase(protocol)) { retriever = new HTTPRetriever(resourceURL, new HttpRetrievalPostProcessor(tile)); } else { String message = Logging.getMessage("layers.TextureLayer.UnknownRetrievalProtocol", resourceURL); throw new RuntimeException(message); } retriever.setConnectTimeout(10000); retriever.setReadTimeout(20000); retriever.call(); }
public HtmlRendererContext open( URL url, String windowName, String windowFeatures, boolean replace) { TestFrame frame = new TestFrame("Cobra Test Tool"); frame.setSize(600, 400); frame.setExtendedState(TestFrame.NORMAL); frame.setVisible(true); HtmlRendererContext ctx = frame.getHtmlRendererContext(); ctx.setOpener(this); frame.navigate(url.toExternalForm()); return ctx; }
private boolean checkServer(int port, boolean ssl) { try { URL url = new URL("http://127.0.0.1:" + port); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.connect(); int length = conn.getContentLength(); StringBuffer text = new StringBuffer(); InputStream is = conn.getInputStream(); InputStreamReader isr = new InputStreamReader(is); int size = 256; char[] buf = new char[size]; int len; while ((len = isr.read(buf, 0, size)) != -1) text.append(buf, 0, len); isr.close(); if (programName.equals("ISN")) return !shutdown(port, ssl); return true; } catch (Exception ex) { return false; } }
/** * Makes a POST request and returns the server response. * * @param urlString the URL to post to * @param nameValuePairs a map of name/value pairs to supply in the request. * @return the server reply (either from the input stream or the error stream) */ public static String doPost(String urlString, Map<String, String> nameValuePairs) throws IOException { URL url = new URL(urlString); URLConnection connection = url.openConnection(); connection.setDoOutput(true); PrintWriter out = new PrintWriter(connection.getOutputStream()); boolean first = true; for (Map.Entry<String, String> pair : nameValuePairs.entrySet()) { if (first) first = false; else out.print('&'); String name = pair.getKey(); String value = pair.getValue(); out.print(name); out.print('='); out.print(URLEncoder.encode(value, "UTF-8")); } out.close(); Scanner in; StringBuilder response = new StringBuilder(); try { in = new Scanner(connection.getInputStream()); } catch (IOException e) { if (!(connection instanceof HttpURLConnection)) throw e; InputStream err = ((HttpURLConnection) connection).getErrorStream(); if (err == null) throw e; in = new Scanner(err); } while (in.hasNextLine()) { response.append(in.nextLine()); response.append("\n"); } in.close(); return response.toString(); }
/** Download data component JAR */ public static boolean downloadInstallerComponent() { DownloadService downloadService = Config.getDownloadService(); DownloadServiceListener listener = downloadService.getDefaultProgressWindow(); String compName = Config.getInstallerLocation(); String compVer = Config.getInstallerVersion(); try { URL codebase = Config.getBasicService().getCodeBase(); URL url = new URL(codebase, compName); String urlstr = url.toString(); if (!downloadService.isResourceCached(url, compVer)) { // The installFailed string is only for debugging. No localization needed Config.trace("Downloading: " + urlstr); // Do download downloadService.loadResource(url, compVer, listener); } } catch (IOException ioe) { Config.trace("Unable to download: " + compName + "/" + compVer); return false; } return true; }
private BufferedImage requestImage(MercatorTextureTile tile, String mimeType) throws URISyntaxException { String pathBase = tile.getPath().substring(0, tile.getPath().lastIndexOf(".")); String suffix = WWIO.makeSuffixForMimeType(mimeType); String path = pathBase + suffix; URL url = WorldWind.getDataFileStore().findFile(path, false); if (url == null) // image is not local return null; if (WWIO.isFileOutOfDate(url, tile.getLevel().getExpiryTime())) { // The file has expired. Delete it. WorldWind.getDataFileStore().removeFile(url); String message = Logging.getMessage("generic.DataFileExpired", url); Logging.logger().fine(message); } else { try { File imageFile = new File(url.toURI()); BufferedImage image = ImageIO.read(imageFile); if (image == null) { String message = Logging.getMessage("generic.ImageReadFailed", imageFile); throw new RuntimeException(message); } this.levels.unmarkResourceAbsent(tile); return image; } catch (IOException e) { // Assume that something's wrong with the file and delete it. gov.nasa.worldwind.WorldWind.getDataFileStore().removeFile(url); this.levels.markResourceAbsent(tile); String message = Logging.getMessage("generic.DeletedCorruptDataFile", url); Logging.logger().info(message); } } return null; }
// implemented for HyperlinkListener public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane ep = (JEditorPane) (e.getSource()); // handle frame events properly if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) (ep.getDocument()); doc.processHTMLFrameHyperlinkEvent(evt); } else // handle normal links { try { URL currentLoc = new URL(location); URL newLoc = new URL(currentLoc, e.getDescription()); setBrowserLocation(newLoc.toString()); } catch (MalformedURLException malUrl) { JOptionPane.showMessageDialog( this, "Malformed URL", "Browser Error", JOptionPane.ERROR_MESSAGE); return; } } } }
void showContent() { URL address = null; try { address = new URL(addressTextField.getText()); } catch (MalformedURLException mue) { showWarning(mainFrame, "地址输入错误"); } System.out.println("getProtocol() " + address.getProtocol()); System.out.println("getHost() " + address.getHost()); System.out.println("getPort() " + address.getPort()); System.out.println("getPath() " + address.getPath()); System.out.println("getFile() " + address.getFile()); System.out.println("getQuery() " + address.getQuery()); }
/** ** Sets the 'port' */ public boolean setPort(int _port) { String uri = this.getURI(); if ((_port > 0) && URIArg.isAbsoluteURL(uri)) { try { URL oldURI = new URL(uri); String proto = oldURI.getProtocol(); String host = oldURI.getHost(); int port = _port; String file = oldURI.getFile(); URL newURI = new URL(proto, host, port, file); this._setURI(newURI.toString()); return true; } catch (MalformedURLException mue) { // error } } return false; }
public static Image getImage(JopSession session, String image) { String fullName; if (session.getRoot() instanceof JopApplet) { String name; try { URL current = ((JApplet) session.getRoot()).getCodeBase(); String current_str = current.toString(); int idx1 = current_str.lastIndexOf('/'); int idx2 = current_str.lastIndexOf(':'); int idx = idx1; if (idx2 > idx) idx = idx2; String path = current_str.substring(0, idx + 1); String url_str; // String url_str = new String( path + name); if (image.substring(0, 5).compareTo("jpwr/") == 0) { idx = image.lastIndexOf('/'); name = image.substring(5, idx); url_str = new String("jar:" + path + "pwr_" + name + ".jar!/" + image); } else { idx = image.lastIndexOf('/'); if (idx == -1) name = new String(image); else name = image.substring(idx + 1); url_str = new String("jar:" + path + "pwrp_" + systemName + "_web.jar!/" + name); } System.out.println("Opening URL: " + url_str); URL url = new URL(url_str); return Toolkit.getDefaultToolkit().getImage(url); } catch (MalformedURLException e) { } return null; } else { // Add default directory /pwrp/img System.out.println("Image: " + image); // int idx = image.lastIndexOf('/'); // if ( idx == -1) // fullName = new String("/pwrp/img/" + image); // else fullName = new String(image); // return Toolkit.getDefaultToolkit().getImage( fullName); try { String name; String url_str; int idx; String path = new String("file://"); if (image.substring(0, 5).compareTo("jpwr/") == 0) { idx = image.lastIndexOf('/'); name = image.substring(5, idx); url_str = new String("$pwr_lib/pwr_" + name + ".jar"); url_str = Gdh.translateFilename(url_str); url_str = new String("jar:" + path + url_str + "!/" + image); } else { idx = image.lastIndexOf('/'); if (idx == -1) name = new String(image); else name = image.substring(idx + 1); url_str = new String("$pwrp_lib/pwrp_" + systemName + ".jar"); System.out.println("java: " + url_str); url_str = Gdh.translateFilename(url_str); url_str = new String("jar:" + path + url_str + "!/" + name); } System.out.println("Opening URL: " + url_str); URL url = new URL(url_str); return Toolkit.getDefaultToolkit().getImage(url); } catch (MalformedURLException e) { } } return null; }
void setIcon() throws Exception { URL url = this.getClass().getResource("/microscope.gif"); if (url == null) return; Image img = createImage((ImageProducer) url.getContent()); if (img != null) setIconImage(img); }
public final void run() { if (socketthread) { socketrun(); return; } socketthread = true; try { boolean flag = false; try { String s = getParameter("member"); int i = Integer.parseInt(s); if (i == 1) flag = true; } catch (Exception _ex) { } loading = getImage(new URL(getCodeBase(), "loading.jpg")); mt = new MediaTracker(this); mt.addImage(loading, 0); m = MessageDigest.getInstance("SHA"); System.out.println(link.class); String s1 = ".file_store_32/"; if (s1 == null) return; link.uid = getuid(s1); link.mainapp = this; link.numfile = 0; for (int j = 0; j < 14; j++) if (flag || !internetname[j].endsWith(".mem")) { for (int k = 0; k < 4; k++) { if (k == 3) return; byte abyte0[] = loadfile(s1 + localname[j], sha[j]); if (abyte0 != null) { if (j > 0) link.putjag(internetname[j], abyte0); break; } try { URL url = new URL(getCodeBase(), internetname[j]); DataInputStream datainputstream = new DataInputStream(url.openStream()); int l = size[j]; byte abyte1[] = new byte[l]; for (int i1 = 0; i1 < l; i1 += 1000) { int j1 = l - i1; if (j1 > 1000) j1 = 1000; datainputstream.readFully(abyte1, i1, j1); showpercent(nicename[j], (i1 * 100) / l, barpos[j]); } datainputstream.close(); FileOutputStream fileoutputstream = new FileOutputStream(s1 + localname[j]); fileoutputstream.write(abyte1); fileoutputstream.close(); } catch (Exception _ex) { } } } System.out.println(cloader.class); cloader cloader1 = new cloader(); cloader1.zip = new ZipFile(s1 + localname[0]); cloader1.link = Class.forName("link"); inner = new mudclient_Debug(); loadMacros(); // inner = (Applet)cloader1.loadClass("mudclient").newInstance(); inner.init(); inner.start(); return; } catch (Exception exception) { System.out.println(exception + " " + exception.getMessage()); exception.printStackTrace(); return; } }