コード例 #1
0
    void closeQuietly(final Closeable closeable) {

      if (closeable != null) {

        try {
          closeable.close();
        } catch (final IOException e) {

          e.printStackTrace();
        }
      }
    }
コード例 #2
0
  protected static RootNode getRootNodeFromBytes(byte[] bytes) {
    RootNode rn = null;
    ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
    ObjectInputStream ois = null;
    try {
      ois = new ObjectInputStream(bis);
      rn = (RootNode) ois.readObject();

    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        bis.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return rn;
  }
コード例 #3
0
    /*
     * (non-Javadoc)
     *
     * @see java.lang.Runnable#run()
     */
    public void run() {

      String line = null;
      try {

        int c;
        StringBuilder buf = new StringBuilder();
        while ((c = this.stderr.read()) != -1) {

          String s = String.valueOf((char) c);
          //                    consoleView.print(s, ConsoleViewContentType.NORMAL_OUTPUT);

          if ((char) c == '\n') {
            line = buf.toString();

            try {
              this.consoleSemaphore.acquire();
              consoleView.print(line + "\n", ConsoleViewContentType.NORMAL_OUTPUT);

            } catch (InterruptedException e) {
              e.printStackTrace();
            } finally {
              this.consoleSemaphore.release();
            }

            buf = new StringBuilder();
            if (isError) {
              log.error("*\t" + line);
            } else {
              log.debug("*\t" + line);
            }
            checkLine(line);

          } else {
            buf.append(s);
          }
        }

        //                this.isr = new InputStreamReader(this.stderr);
        //                this.br = new BufferedReader(this.isr);
        //
        //                log.debug("awaiting input...");
        //
        //                while ((line = this.br.readLine()) != null) {
        //
        //                    consoleView.print(line + "\n", ConsoleViewContentType.NORMAL_OUTPUT);
        //                    // NB. this is not a logger as we don't want to be able to turn
        //                    // this off
        //                    // If the level of logging from the child process is verbose,
        //                    // change the logging level of the spawned process.
        //
        //                    if (isError){
        //                        log.error("*\t" + line);
        //                    }
        //                    else {
        //                        log.debug("*\t" + line);
        //                    }
        //                    checkLine(line);
        //
        //                }
      } catch (final IOException e) {

        e.printStackTrace();
      } finally {
        doFinalCheck();
      }
    }