private Object open(IRI uri, boolean in) {

    IRI relative = uri.isAbsolute() ? base.relativize(uri, IRIRelativize.CHILD) : uri;

    if (relative.isAbsolute())
      throw new IllegalArgumentException(
          "This  TestInputStreamFactory only knows about '" + base + "'.");

    String relPath = relative.toString();
    if (relPath.length() - relPath.lastIndexOf('.') > 5) {
      relPath = relPath + ".rdf";
      relative = iriFactory.create(relPath);
    }

    if (mapBase != null) {
      // System.out.println("LazyURL: " + relative + " " + mapBase);
      try {
        URL url = mapBase.create(relative).toURL();
        if (!in) {
          if (url.getProtocol().equalsIgnoreCase("file"))
            return new FileOutputStream(url.getFile());
          throw new IllegalArgumentException("Can only save to file: scheme");
        }
        return new LazyURLInputStream(url);
      } catch (MalformedURLException e) {
        throw new JenaException(e);
      } catch (IOException e) {
        e.printStackTrace();
        throw new JenaException(e);
      }
    }
    if (!in) throw new IllegalArgumentException("Can only save to URLs");

    if (zip != null) return new LazyZipEntryInputStream(zip, relPath);
    else return TestInputStreamFactory.getInputStream(property + relPath);
  }
 /**
  * opens the file, and really does it - not a delayed lazy opening.
  *
  * @param str the URI to open
  * @return null on some failures
  * @throws IOException
  */
 public InputStream fullyOpen(String str) throws IOException {
   InputStream in = open(iriFactory.create(str));
   if (in instanceof LazyInputStream && !((LazyInputStream) in).connect()) return null;
   return in;
 }
 /**
  * A lazy open. The I/O only starts, and resources are only allocated on first read.
  *
  * @param str The URI to open
  */
 public InputStream open(String str) {
   return open(iriFactory.create(str));
 }
 public OutputStream openOutput(String str) {
   OutputStream foo = (OutputStream) open(iriFactory.create(str), false);
   //	System.out.println(foo.toString());
   return foo;
 }