Package java.io

Examples of java.io.OutputStream


      "Content-Length: " + reply_bytes.length + NL +
      NL;

    // System.out.println( "writing reply:" + reply_header );

    OutputStream os = request.getOutputStream();
   
    os.write( reply_header.getBytes());

    if ( do_gzip ){
     
      GZIPOutputStream gzos = new GZIPOutputStream(os);
     
      gzos.write( reply_bytes );
     
      gzos.finish();
     
    }else{
   
      os.write( reply_bytes );
    }
   
    os.flush();
  }
View Full Code Here


    String    file_type,
    InputStream  input_stream )

    throws IOException
  {
    OutputStream  os = getOutputStream();

    String response_type = HTTPUtils.guessContentTypeFromFileType(file_type);
   
    if ( explicit_gzip != 2 && HTTPUtils.useCompressionForFileType(response_type)){
     
      Map headers = request.getHeaders();
     
      String  accept_encoding = (String)headers.get("accept-encoding");
     
      if ( HTTPUtils.canGZIP(accept_encoding)){

        is_gzipped = true;
       
        os = new GZIPOutputStream(os);
       
        header_map.put("Content-Encoding", "gzip");
      }
    }
   
    setContentType( response_type );

    byte[]  buffer = new byte[4096];

    while(true){

      int  len = input_stream.read(buffer);

      if ( len <= 0 ){

        break;
      }

      os.write( buffer, 0, len );
    }
   
    if ( os instanceof GZIPOutputStream ){
     
      ((GZIPOutputStream)os).finish();
View Full Code Here

        v.set(XMLBeans.INDEX_BEANCONNECTIONS,
            BeanConnection.getConnections(tabIndex));
        XMLBeans xml = new XMLBeans(m_beanLayout, m_bcSupport, tabIndex);
        xml.write(sFile, v);
      } /* binary */ else {
        OutputStream os = new FileOutputStream(sFile);
        ObjectOutputStream oos = new ObjectOutputStream(os);
        oos.writeObject(beans);
        oos.writeObject(BeanConnection.getConnections(tabIndex));
        oos.flush();
        oos.close();
View Full Code Here

                XMLBeans xml = new XMLBeans(m_beanLayout, m_bcSupport, XMLBeans.DATATYPE_USERCOMPONENTS,
                    m_mainKFPerspective.getCurrentTabIndex());
                xml.write(sFile2, m_userComponents);
              }
              else { */
          OutputStream os = new FileOutputStream(sFile2);
          ObjectOutputStream oos = new ObjectOutputStream(os);
          oos.writeObject(m_userComponents);
          oos.flush();
          oos.close();
          //}
View Full Code Here

            return true;
        }

        public void run() {
            try {
                OutputStream out = write.getOutputStream();
                InputStream in = read.getInputStream();
                while (true) {
                    boolean more;
                    if (client) {
                        more = processClient(in, out);
View Full Code Here

        basePath = new File(basePath).getPath();
        try {
            if (new File(destFile).isDirectory()) {
                throw new IOException("Can't create the file as a directory with this name already exists: " + destFile);
            }
            OutputStream out = new BufferedOutputStream(new FileOutputStream(destFile));
            ZipOutputStream zipOut;
            if (jar) {
                zipOut = new JarOutputStream(out);
            } else {
                zipOut = new ZipOutputStream(out);
View Full Code Here

    }

    private void connect(String url) throws IOException {
        socket = NetUtils.createSocket(url, 21, false);
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
        reader = new BufferedReader(new InputStreamReader(in));
        writer = new PrintWriter(new OutputStreamWriter(out, Constants.UTF8));
        readCode(220);
    }
View Full Code Here

    private void zip(String zipFileName, String base, ArrayList<String> source) {
        if (IOUtils.exists(zipFileName)) {
            IOUtils.delete(zipFileName);
        }
        OutputStream fileOut = null;
        try {
            fileOut = IOUtils.openFileOutputStream(zipFileName, false);
            ZipOutputStream zipOut = new ZipOutputStream(fileOut);
            for (String fileName : source) {
                String f = IOUtils.getCanonicalPath(fileName);
View Full Code Here

                fileName = fileName.replace('\\', SysProperties.FILE_SEPARATOR.charAt(0));
                fileName = fileName.replace('/', SysProperties.FILE_SEPARATOR.charAt(0));
                if (fileName.startsWith(SysProperties.FILE_SEPARATOR)) {
                    fileName = fileName.substring(1);
                }
                OutputStream o = null;
                try {
                    o = IOUtils.openFileOutputStream(targetDir + SysProperties.FILE_SEPARATOR + fileName, false);
                    IOUtils.copy(zipIn, o);
                    o.close();
                } finally {
                    IOUtils.closeSilently(o);
                }
                zipIn.closeEntry();
            }
View Full Code Here

     */
    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

TOP

Related Classes of java.io.OutputStream

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.