Examples of OutputStream


Examples of java.io.OutputStream

     */
    synchronized void receive(FileSystem fs, String fileName) throws IOException {
        connect();
        try {
            InputStream in = socket.getInputStream();
            OutputStream out = fs.openFileOutputStream(fileName, false);
            IOUtils.copy(in, out);
            out.close();
        } finally {
            socket.close();
        }
        server.trace("closed");
    }
View Full Code Here

Examples of java.io.OutputStream

     * @param skip the number of bytes to skip
     */
    synchronized void send(FileSystem fs, String fileName, long skip) throws IOException {
        connect();
        try {
            OutputStream out = socket.getOutputStream();
            InputStream in = fs.openFileInputStream(fileName);
            IOUtils.skipFully(in, skip);
            IOUtils.copy(in, out);
            in.close();
        } finally {
View Full Code Here

Examples of juzu.io.OutputStream

    return key.toString();
  }

  public StringBuilder render() throws IOException {
    StringBuilder buffer = new StringBuilder();
    OutputStream consumer = OutputStream.create(Tools.UTF_8, buffer);
    render(consumer);
    return buffer;
  }
View Full Code Here

Examples of net.kuujo.vertigo.io.stream.OutputStream

      public void handle(final Task task) {
        // Iterate through existing streams and try to determine
        // whether any of them have been removed from the network.
        Iterator<OutputStream> iter = streams.iterator();
        while (iter.hasNext()) {
          final OutputStream stream = iter.next();
          boolean exists = false;
          for (OutputStreamContext output : update.streams()) {
            if (output.address().equals(stream.address())) {
              exists = true;
              break;
            }
          }

          // If a stream was removed from the network, close
          // and remove the connection regardless of whether the
          // close is actually successful.
          if (!exists) {
            stream.close(new Handler<AsyncResult<Void>>() {
              @Override
              public void handle(AsyncResult<Void> result) {
                if (result.failed()) {
                  log.error(String.format("%s - Failed to close output stream: %s", DefaultOutputPort.this, stream));
                } else {
                  log.info(String.format("%s - Closed output stream: %s", DefaultOutputPort.this, stream));
                }
              }
            });
            iter.remove();
          }
        }

        // Now try to determine whether any streams were added to the network.
        final List<OutputStream> newStreams = new ArrayList<>();
        for (OutputStreamContext output : update.streams()) {
          boolean exists = false;
          for (OutputStream stream : streams) {
            if (stream.address().equals(output.address())) {
              exists = true;
              break;
            }
          }
          if (!exists) {
            log.info(String.format("%s - Creating stream: %s", DefaultOutputPort.this, output));
            newStreams.add(new DefaultOutputStream(vertx, output));
          }
        }

        // If the port is open then that means streams have already
        // been set up. We need to add the new streams carefully
        // because it's possible that user code may be sending messages
        // on the port. If messages are sent to a stream that's not
        // yet open then an exception will be thrown.
        if (open) {
          final CountingCompletionHandler<Void> counter = new CountingCompletionHandler<Void>(newStreams.size());
          counter.setHandler(new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              task.complete();
            }
          });

          // Start each stream and add the stream to the streams
          // list only once the stream has been successfully opened.
          // The update lock by the task runner will ensure that we don't
          // accidentally open up two of the same stream even if the
          // configuration is updated again.
          for (final OutputStream stream : newStreams) {
            stream.open(new Handler<AsyncResult<Void>>() {
              @Override
              public void handle(AsyncResult<Void> result) {
                if (result.failed()) {
                  log.error(String.format("%s - Failed to open output stream: %s", DefaultOutputPort.this, stream));
                } else {
View Full Code Here

Examples of org.apache.lucene.store.OutputStream

        Directory dest = getDirectory();
        String[] files = dir.list();
        for (int i = 0; i < files.length; i++) {
            InputStream in = dir.openFile(files[i]);
            try {
                OutputStream out = dest.createFile(files[i]);
                try {
                    long remaining = in.length();
                    while (remaining > 0) {
                        int num = (int) Math.min(remaining, buffer.length);
                        in.readBytes(buffer, 0, num);
                        out.writeBytes(buffer, num);
                        remaining -= num;
                    }
                } finally {
                    out.close();
                }
            } finally {
                in.close();
            }
        }
View Full Code Here

Examples of org.apache.yoko.orb.CORBA.OutputStream

        TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_char);
        CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
        CorbaStreamable streamable = new CorbaStreamable(obj, objName);
       
        Buffer buf = new Buffer();
        OutputStream oStream = new OutputStream(buf);
        oStream.write_char('c');
       
        InputStream iStream = oStream.create_input_stream();
        streamable._read(iStream);
        CorbaPrimitiveHandler streamableObj = (CorbaPrimitiveHandler)streamable.getObject();
        Object o = streamableObj.getValue();
       
        assertTrue(o instanceof Character);
View Full Code Here

Examples of org.omg.CORBA.portable.OutputStream

                throw new org.omg.CORBA.BAD_PARAM(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
            }
            try {
                // invocation and sending result
                Object result = invocationProxy.invoke(operationName, inputInstances);
                OutputStream out = rh.createReply();
                if (types.getOutputType() != null) {
                    TypeTree tree = types.getOutputType();
                    TypeHelpersProxy.write(tree.getRootNode(), out, result);
                }
                return out;
            } catch (InvocationException ie) {
                // handling user exception
                try {
                    OutputStream out = rh.createExceptionReply();
                    Class<?> exceptionClass = ie.getTargetException().getClass();
                    TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass, null);
                    String exceptionId = Utils.getTypeId(exceptionClass);
                    out.write_string(exceptionId);
                    TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException());
                    return out;
                } catch (Exception e) {
                    logger.log(Level.WARNING, "Exception during handling invocation exception", e);
                }
View Full Code Here

Examples of org.omg.CORBA_2_3.portable.OutputStream

            // always return false.

            InputStream in = null;
            try {
                try {
                    OutputStream out =
                            (OutputStream) _request(operationName, true);
                    stubStrategy.writeParams(out, params);
                    trace("sent request: " + operationName);
                    in = (InputStream) _invoke(out);
                    if (stubStrategy.isNonVoid()) {
View Full Code Here

Examples of org.pdfclown.bytes.OutputStream

  public void save(
    java.io.File file,
    SerializationModeEnum mode
    ) throws IOException
  {
    OutputStream outputStream;
    java.io.BufferedOutputStream baseOutputStream;
    try
    {
      file.createNewFile();
      baseOutputStream = new java.io.BufferedOutputStream(
        new java.io.FileOutputStream(file)
        );
      outputStream = new OutputStream(baseOutputStream);
    }
    catch(Exception e)
    {throw new IOException(file.getPath() + " file couldn't be created.",e);}
    try
    {
View Full Code Here

Examples of org.red5.server.stream.OutputStream

    if (log.isDebugEnabled())
      log.debug("Channel id range start: {}", channelId);
    final Channel data = getChannel(channelId++);
    final Channel video = getChannel(channelId++);
    final Channel audio = getChannel(channelId++);
    return new OutputStream(video, audio, data);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.