Package com.caucho.vfs

Examples of com.caucho.vfs.ReadStream


      if (ts != null) {
        if (_os == null)
          openLog();

        try {
          ReadStream is = ts.openRead();

          try {
            is.writeToStream(_os);
          } finally {
            is.close();
          }
        } catch (IOException e) {
          e.printStackTrace();
        } finally {
          ts.destroy();
View Full Code Here


      out.print(Html.escapeHtml(file));
      out.print("</b>");
      out.print("</code>");
      out.println("<p>");

      ReadStream is;
      try {
        is = path.openRead();
      } catch (java.io.FileNotFoundException ex) {
        out.println("<font color='red'><b>File not found: " + Html.escapeHtml(path.getPath()) + "</b></font>");
        out.println("</body>");
        out.println("</html>");
        return;
      }

      String line;
      out.print("<pre>");

      boolean h = false// true if currently highlighting
      boolean m = false// true if marked

      while ((line = is.readln()) != null) {
        // check for marker
        if (!m && re_mrk != null && re_mrk.matcher(line).matches()) {
          out.print("<a name='code-highlight'></a>");
          m = true;
        }

        // check for highlighting begin
        if (!h && re_beg != null && re_beg.matcher(line).matches()) {
          h = true;
          out.print("<b class='code-highlight'>");
          if  (!m && re_mrk == null) {
            out.print("<a name='code-highlight'></a>");
            m = true;
          }
        }

        // send string out
        // handle '<' character and '>' character
        int l = line.length();
        for (int i = 0; i < l; i++) {
          int ch = line.charAt(i);
          if (ch == '<') {
            if (h) out.print("<span class='face-xmlelement'>");
            out.print("&lt;");
          } else if (ch == '>') {
            out.print("&gt;");
            if (h) out.print("</span>");
          }
          else
            out.print((char) ch);
        }
        out.println();

        // check for highlighting end
        if (h && (re_end == null || (re_end != null && re_end.matcher(line).matches()))) {
          h = false;
          out.print("</b>");
        }
      }

      is.close();
      if (h)
        out.print("</b>");
      out.println("</pre>");
      out.println("</body>");
      out.println("</html>");
View Full Code Here

    Path path = Vfs.lookup("/home/ferg/majordomo/archive/resin-interest.0006");
    Path dst = Vfs.lookup("/tmp/dst");
    dst.mkdirs();

    ReadStream is = path.openRead();
    try {
      parseMail(is, dst);
    } finally {
      is.close();
    }
    pw.println("done");
  }
View Full Code Here

    throws IOException
  {
    if (isDone)
      return null;
    else if (readStream == null)
      readStream = new ReadStream(this, null);
    else if (! isPartDone) {
      int len;
      while ((len = read(dummyBuffer, 0, dummyBuffer.length)) >= 0) {
      }
View Full Code Here

    int count = 0;
    HashMap map = new HashMap();
    HashMap subjectMap = new HashMap();

    ReadStream rawIs = path.openRead();
    MboxStream mboxStream = new MboxStream(rawIs);
    ReadStream message;

    while ((message = mboxStream.openRead()) != null) {
      MboxMessage msg = new MboxMessage(count++);

      String id = (String) message.getAttribute("Message-Id");

      id = normalizeMessageId(id);
     
      msg.setMessageId(id);
     
      msg.setFrom((String) message.getAttribute("From"));
      String subject = (String) message.getAttribute("Subject");
      msg.setSubject(subject);

      messages.add(msg);

      String inReplyTo = (String) message.getAttribute("In-Reply-To");

      inReplyTo = normalizeMessageId(inReplyTo);

      MboxMessage parent = null;
      if (inReplyTo != null)
View Full Code Here

  {
    String publicId = entity.getPublicId();
    String systemId = entity.getSystemId();
    String value = null;
    InputSource source = null;
    ReadStream is = null;

    if (_entityResolver != null)
      source = _entityResolver.resolveEntity(publicId, systemId);

    if (source != null && source.getByteStream() != null)
      is = Vfs.openRead(source.getByteStream());
    else if (source != null && source.getCharacterStream() != null)
      is = Vfs.openRead(source.getCharacterStream());
    else if (source != null && source.getSystemId() != null &&
             _searchPath.lookup(source.getSystemId()).isFile()) {
      _owner.addDepend(_searchPath.lookup(source.getSystemId()));
      is = _searchPath.lookup(source.getSystemId()).openRead();
    }
    else if (systemId != null && ! systemId.equals("")) {
      String path = systemId;
      if (path.startsWith("file:"))
        path = path.substring(5);
      if (_searchPath != null && _searchPath.lookup(path).isFile()) {
        _owner.addDepend(_searchPath.lookup(path));
        is = _searchPath.lookup(path).openRead();
      }
    }

    if (is == null)
      return false;

    _filename = systemId;
    _systemId = systemId;

    Path oldSearchPath = _searchPath;
    Path path = is.getPath();
    if (path != null) {
      _owner.addDepend(path);
     
      if (_searchPath != null) {
        _searchPath = path.getParent();
View Full Code Here

    try {
      Path path = Vfs.lookup(_systemId);

      if (path.canRead()) {
        ReadStream is = path.openRead();

        lines.append("\n");

        try {
          for (int i = 1; i < _line + 3; i++) {
            String line = is.readLine();

            if (line == null)
              break;

            if (_line - 3 < i && i < _line + 3) {
              lines.append(i).append(": ").append(line).append("\n");
            }
          }
        } finally {
          is.close();
        }
      }
    } catch (IOException e) {
    }
View Full Code Here

    else {
      _uriPwd = "/";
    }
    _parseState.setUriPwd(_uriPwd);

    ReadStream is = path.openRead();
    path.setUserPath(uri);

    try {
      parseJsp(is);
    } finally {
      is.close();
      for (int i = 0; i < _includes.size(); i++) {
        Include inc = _includes.get(i);
        inc._stream.close();
      }
    }
View Full Code Here

  {
    String resinConf = CauchoSystem.getResinConfig();
    boolean verbose = false;

    try {
      ReadStream is;
      String name;
      int shift = 0;

      while (argv.length > shift) {
        if (argv[shift].equals("-v")) {
View Full Code Here

    throws IOException
  {
    if (options != null)
      env.stub(L.l("`{0}' is ignored", "options"));

    ReadStream is = null;

    try {
      is = path.openRead();

      getImpl().parseXMLDocument(_delegate, is, path.getPath());
    }
    catch (SAXException ex) {
      env.warning(ex);

      return false;
    }
    catch (IOException ex) {
      env.warning(ex);
      return false;
    }
    finally {
      if (is != null) {
        is.close();
      }
    }

    return true;
  }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.ReadStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.