Examples of OutputStream


Examples of java.io.OutputStream

            if (dataSoc == null) {
                throw new IOException("Cannot open data connection.");
            }

            // create output stream
            OutputStream os = dataSoc.getOutputStream();
            if (factory.isZipMode()) {
                os = new DeflaterOutputStream(os);
            }
            return os;
        } catch (IOException ex) {
View Full Code Here

Examples of java.io.OutputStream

        int maxRate = 0;
        if (transferRateRequest != null) {
            maxRate = transferRateRequest.getMaxDownloadRate();
        }

        OutputStream out = getDataOutputStream();
        try {
            return transfer(session, true, in, out, maxRate);
        } finally {
            IoUtils.close(out);
        }
View Full Code Here

Examples of java.io.OutputStream

     * org.apache.ftpserver.FtpDataConnection2#transferToClient(java.lang.String
     * )
     */
    public final void transferToClient(FtpSession session, final String str)
            throws IOException {
        OutputStream out = getDataOutputStream();
        Writer writer = null;
        try {
            writer = new OutputStreamWriter(out, "UTF-8");
            writer.write(str);

View Full Code Here

Examples of java.io.OutputStream

            session.write(new DefaultFtpReply(
                    FtpReply.REPLY_150_FILE_STATUS_OKAY, "FILE: " + fileName));

            // get data from client
            boolean failure = false;
            OutputStream os = null;

            DataConnection dataConnection;
            try {
                dataConnection = session.getDataConnection().openConnection();
            } catch (Exception e) {
                LOG.debug("Exception getting the input data stream", e);
                session.write(LocalizedDataTransferFtpReply.translate(session, request, context,
                        FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "STOU",
                        fileName, file));
                return;
            }

            long transSz = 0L;
            try {

                // open streams
                os = file.createOutputStream(0L);

                // transfer data
                transSz = dataConnection.transferFromClient(session.getFtpletSession(), os);

                // attempt to close the output stream so that errors in
                // closing it will return an error to the client (FTPSERVER-119)
                if(os != null) {
                    os.close();
                }

                LOG.info("File uploaded {}", fileName);

                // notify the statistics component
View Full Code Here

Examples of java.io.OutputStream

        throw new InterruptedIOException("Could not connect to " + sockAddr);
    }

    public static boolean write(final Socket socket, final byte[] b, final long delay, final int maxRetry)
            throws IOException {
        final OutputStream sockout = socket.getOutputStream();
        for(int i = 0; i < maxRetry; i++) {
            try {
                sockout.write(b);
                sockout.flush();
                return true;
            } catch (IOException e) {
                if(LOG.isWarnEnabled()) {
                    LOG.warn("Failed to write to socket: " + socket.getRemoteSocketAddress() + " #"
                            + i);
View Full Code Here

Examples of java.io.OutputStream

          if(entry.isDirectory()) {
            (new File(targetDir, entry.getName())).mkdir();
            continue;
          }
          InputStream in = zipFile.getInputStream(entry);
          OutputStream out = new FileOutputStream(new File(targetDir, entry.getName()));   
          try {
            WGUtils.inToOut(in, out, 2048);
          } finally {
            out.close();
            in.close();
          }
        }
        zipFile.close();
    } finally {
View Full Code Here

Examples of java.io.OutputStream

  public static final void unzip(InputStream zipIn, File targetDir) throws ZipException, IOException {
    File temp = File.createTempFile("UNZIP", null);
    temp.deleteOnExit();
   
    try {
      OutputStream out = new FileOutputStream(temp);
      try {
        WGUtils.inToOut(zipIn, out, 2048);
      } finally {
        out.close();
      }
      unzip(temp, targetDir);
    } finally {
      temp.delete();
    }
View Full Code Here

Examples of java.io.OutputStream

            int content_length = Integer.parseInt( cl_str );
           
            ByteArrayOutputStream  baos    = null;
            FileOutputStream    fos      = null;
         
            OutputStream  data_os;
           
            if ( content_length <= 256*1024 ){
             
              baos = new ByteArrayOutputStream();
           
              data_os  = baos;
             
            }else{
             
              post_file  = AETemporaryFileHandler.createTempFile();
             
              post_file.deleteOnExit();
             
              fos  = new FileOutputStream( post_file );
             
              data_os  = fos;
            }
           
            while( content_length > 0 ){
             
              int  len = is.read( buffer, 0, Math.min( content_length, buffer.length ));
             
              if ( len < 0 ){
               
                throw( new TRTrackerServerException( "premature end of input stream" ));
              }
             
              data_os.write( buffer, 0, len );
             
              content_length -= len;
            }
           
            if ( baos != null ){
View Full Code Here

Examples of java.io.OutputStream

    Map<Content, String> contentEntries = new HashMap<Content, String>();
    File furnitureLibraryFile = new File(furnitureLibraryName);
    File tmpFile = null;
    try {
      tmpFile = File.createTempFile("temp", ".sh3f");
      OutputStream out = new FileOutputStream(tmpFile);
      if (out != null) {
        // Create a zip output on file 
        zipOut = new ZipOutputStream(out);
        // Write furniture description file in first entry
        zipOut.putNextEntry(new ZipEntry(DefaultFurnitureCatalog.PLUGIN_FURNITURE_CATALOG_FAMILY + ".properties"));
View Full Code Here

Examples of java.io.OutputStream

  /**
   * Copy the content of <code>in</code> stream to <code>file</code>.
   */
  private void copyContentToFile(InputStream in, File file) throws IOException {
    byte [] buffer = new byte [8192];
    OutputStream out = null;
    try {
      out = new FileOutputStream(file);
      int size;
      while ((size = in.read(buffer)) != -1) {
        out.write(buffer, 0, size);
      }
    } finally {
      try {
        if (out != null) {         
          out.close();
        }
      } catch (IOException ex) {
        throw new IOException("Can't close file " + file);
      }
    }
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.