Package java.io

Examples of java.io.InputStream.available()


          Random rnd = new Random();

          public void serialEvent(SerialPortEvent event) {
            try {
              if (event.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
                int n = ins.available();
                byte[] buffer = new byte[n];
                n = ins.read(buffer, 0, n);
                for (int i = 0; i < n; ++i) {
                  byte b = buffer[i];
                  linebuf[inp++] = b;
View Full Code Here


    p.setSerialPortParams(baudRate, dataBits + requiredExtraBits,
        SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    p.enableReceiveTimeout(10000);

    InputStream in = p.getInputStream();
    while (in.available() != 0) {
      in.read();
    }

    System.out.println("Waiting for A...");
View Full Code Here

                        throw new AbortedFetchException(url, AbortedFetchReason.INTERRUPTED);
                    }
                }

                content = out.toByteArray();
                needAbort = truncated || (in.available() > 0);
            } catch (IOException e) {
                // We don't need to abort if there's an IOException
                throw new IOFetchException(url, e);
            } finally {
                safeAbort(needAbort, request);
View Full Code Here

  {
    InputStream in = null;

    try {
      in = this.getClass().getResourceAsStream(messageFile);
      return in.available();
    } finally {
      in.close();
    }
  }
}
View Full Code Here

    long size = 0L;

    try {
      // get available bytes in input stream
      InputStream in = part.getInputStream();
      Integer inSize = in.available();
     
      if (inSize == null || inSize < 1)
        size = IOUtils.getInputStreamSize(in);
      else
        size = inSize;
View Full Code Here

      is = this.data.getInputStream();
      lis = new LineReadingInputStream(is);

      String line;
      line = lis.readLine(100, 100, false); // really it's US-ASCII, but ISO-8859-1 is close enough.
      while((is.available() > 0) && !line.equals(boundary)) {
        line = lis.readLine(100, 100, false);
      }

      boundary = "\r\n" + boundary;
View Full Code Here

      RandomAccessBucket filedata = null;
      String name = null;
      String filename = null;
      String contentType = null;

      while(is.available() > 0) {
        name = null;
        filename = null;
        contentType = null;
        // chomp headers
        while((line = lis.readLine(200, 200, true)) /* should be UTF-8 as we told the browser to send UTF-8 */ != null) {
View Full Code Here

        // we should be at the data now. Start reading it in, checking for the
      // boundary string

        // we can only give an upper bound for the size of the bucket
        filedata = this.bucketfactory.makeBucket(is.available());
        bucketos = filedata.getOutputStream();
        // buffer characters that match the boundary so far
      // FIXME use whatever charset was used
        byte[] bbound = boundary.getBytes("UTF-8"); // ISO-8859-1? boundary should be in US-ASCII
        int offset = 0;
View Full Code Here

        bucketos = filedata.getOutputStream();
        // buffer characters that match the boundary so far
      // FIXME use whatever charset was used
        byte[] bbound = boundary.getBytes("UTF-8"); // ISO-8859-1? boundary should be in US-ASCII
        int offset = 0;
        while((is.available() > 0) && (offset < bbound.length)) {
          byte b = (byte) is.read();

          if(b == bbound[offset])
            offset++;
          else if((b != bbound[offset]) && (offset > 0)) {
View Full Code Here

      inputStream = null;
        outputStream.close();
      outputStream = null;

        bis = output.getInputStream();
        while(bis.available() > 0){
          outsb.append((char)bis.read());
        }
      } catch (IOException e) {
        outsb.append("Bucket error?: " + e.getMessage());
        Logger.error(this, "Bucket error?: " + e, e);
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.