Package java.io

Examples of java.io.BufferedInputStream.available()


            InputStream stream = connection.getInputStream();
            Debug.logInfo("getContentLength is :"+contentLength, module);

            in = new BufferedInputStream(stream);

            long totalBytes = in.available();
            Debug.logInfo("totalBytes is : "+totalBytes, module);

            byte[] b = new byte[1024];

            FileOutputStream file = new FileOutputStream(libPath);
View Full Code Here


                // So we just read without blocking, because we do not know when to
                // stop reading, so we cannot block
                // TODO propery implement support for chunked transfer, i.e. to
                // know when we have read the whole request, and therefore allow
                // the reading to block
                while(in.available() > 0 && ((length = in.read(buffer)) != -1)) {
                    out.write(buffer, 0, length);
                }
            }
            else {
                // The reqest has no body, or it has a transfer encoding we do not support.
View Full Code Here

                }
            }
            else {
                // The reqest has no body, or it has a transfer encoding we do not support.
                // In either case, we read any data available
                while(in.available() > 0 && ((length = in.read(buffer)) != -1)) {
                    out.write(buffer, 0, length);
                }
            }
            out.flush();
        } catch (IOException e) {
View Full Code Here

    try
    {
      // read byte[] from jar-entry
      InputStream in =
        new BufferedInputStream(repository.getInputStream(file));
      byte[] byteCode = new byte[in.available()];
      in.read(byteCode);

      // define the corresponding package, if neccessary
      this.definePackageForClass(className);
View Full Code Here

        // read the request
        InputStream in = new BufferedInputStream(s.getInputStream());
        byte command = (byte)in.read();
        byte[] lengthb = new byte[4];
        while(in.available() < 4);
        in.read(lengthb);
        int length = SimpleP2P.byteArray2int(lengthb);
        int answer = SimpleP2P.REPLY_ERROR;

        if (length > 0)
View Full Code Here

        int answer = SimpleP2P.REPLY_ERROR;

        if (length > 0)
        {
          byte[] data = new byte[length];
          while(in.available() < length);
          in.read(data);

          // process the request
          switch (command)
          {
View Full Code Here

      zipOut.write(state);
      zipOut.close();

      // return data
      BufferedInputStream fin = new BufferedInputStream(new FileInputStream(file));
      byte[] buffer = new byte[fin.available()];
      fin.read(buffer);
     
      return buffer;
    } catch (Throwable e)
    {
View Full Code Here

    {
      // BufferedInputStream so we can for sure
      // read all data in one call to read(byte[])!!!
      InputStream in = new BufferedInputStream(oin);

      byte[] retval = new byte[in.available()];
      in.read(retval);
      in.close();

      return retval;
    } catch (IOException e)
View Full Code Here

    {
      Resource r = agentServices.requestResource(this.url, false);
      InputStream in = new BufferedInputStream(r.getInputStream());

      // read all data
      this.payload = new byte[in.available()];
      in.read(this.payload);

      // even if we failed, we have no other option
      return;
    }
View Full Code Here

      // read all of gpg's output after
      // process has terminated
      if (p.waitFor() != 0)
        return null;
      byte[] gpgoutput = new byte[in.available()];
      in.read(gpgoutput);

      // go through all lines and see, if we
      // get an "[GNUPG:] IMPORT_OK" line
      String[] lines = new String(gpgoutput).split("\n");
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.