Beispiel #1
0
 public PrivateReader(String file, String head, String foot)
     throws MalformedURLException, IOException {
   header = head;
   footer = foot;
   if (file.indexOf("://") < 0) {
     internal = new BufferedReader(new FileReader(file));
   } else if (file.startsWith("https:")) {
     log.debug("trying ssl connection...");
     System.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory");
     HttpsURLConnection conn = (HttpsURLConnection) (new URL(file)).openConnection();
     internal = new BufferedReader(new InputStreamReader(conn.getInputStream()), 200000);
   } else if (file.endsWith(".z") || file.endsWith(".gz")) {
     internal =
         new InputStreamReader(
             new GZIPInputStream((new URL(file)).openConnection().getInputStream()));
   } else internal = new InputStreamReader((new URL(file)).openConnection().getInputStream());
 }
  /** adds an entry to the class path */
  public void addClassPath(String cp) {
    UnixFile f = new UnixFile(cp);

    // use the URLClassLoader
    if (useSystem) {
      try {
        addURL(f.toURL());
        if (verbose)
          System.out.println("RJavaClassLoader: added '" + cp + "' to the URL class path loader");
        // return; // we need to add it anyway so it appears in .jclassPath()
      } catch (Exception ufe) {
      }
    }

    UnixFile g = null;
    if (f.isFile() && (f.getName().endsWith(".jar") || f.getName().endsWith(".JAR"))) {
      g = new UnixJarFile(cp);
      if (verbose)
        System.out.println(
            "RJavaClassLoader: adding Java archive file '" + cp + "' to the internal class path");
    } else if (f.isDirectory()) {
      g = new UnixDirectory(cp);
      if (verbose)
        System.out.println(
            "RJavaClassLoader: adding class directory '" + cp + "' to the internal class path");
    } else if (verbose)
      System.err.println(
          f.exists()
              ? ("WARNING: the path '"
                  + cp
                  + "' is neither a directory nor a .jar file, it will NOT be added to the internal class path!")
              : ("WARNING: the path '"
                  + cp
                  + "' does NOT exist, it will NOT be added to the internal class path!"));

    if (g != null && !classPath.contains(g)) {
      // this is the real meat - add it to our internal list
      classPath.add(g);
      // this is just cosmetics - it doesn't really have any meaning
      System.setProperty(
          "java.class.path",
          System.getProperty("java.class.path") + File.pathSeparator + g.getPath());
    }
  }