/** * load from specified JarInputStream * * @param fis Jar Input Stream * @param mnemo the name for the text file */ private void addToCache(JarInputStream fis, String mnemo) { String text = ""; byte[] buf = new byte[4096]; int i = 0; try { while ((i = fis.read(buf)) != -1) { text += new String(buf, 0, i); } } catch (IOException ignored) { } helpcache.put(mnemo, text); }
private static Hashtable<String, String> getManifestAttributes(Manifest manifest) { Hashtable<String, String> h = new Hashtable<String, String>(); try { Attributes attrs = manifest.getMainAttributes(); Iterator it = attrs.keySet().iterator(); while (it.hasNext()) { String key = it.next().toString(); h.put(key, attrs.getValue(key)); } } catch (Exception ignore) { } return h; }
/** * Loads from specified file * * @param file * @param mnemo the name for the text file */ private void addToCache(File file, String mnemo) { BufferedInputStream fis; try { fis = new BufferedInputStream(new FileInputStream(file)); } catch (FileNotFoundException e) { System.out.println("Warning! File '" + file + "' not found!"); return; } String text = ""; byte[] buf = new byte[4096]; int i = 0; try { while ((i = fis.read(buf)) != -1) { text += new String(buf, 0, i); } fis.close(); } catch (IOException ignored) { } helpcache.put(mnemo, text); }