public void close() throws IOException {
    for (int i = 1; i < databuffer.length; i++) {
      super.write(databuffer[i]);
    }

    super.flush();
    super.close();
  }
 public void writeln(String s) throws MessagingException {
   try {
     byte abyte0[] = getBytes(s);
     super.out.write(abyte0);
     super.out.write(newline);
   } catch (Exception exception) {
     throw new MessagingException("IOException", exception);
   }
 }
 @Override
 public void write(int c) throws IOException {
   if (c == '\n') {
     super.write(0xa);
     super.write(0xd);
   } else {
     super.write(c);
   }
 }
 @Override
 public void write(int oneByte) throws IOException {
   if (oneByte == '\r') {
     state = STATE_CR;
   } else if ((state == STATE_CR) && (oneByte == '\n')) {
     state = STATE_CRLF;
   } else if ((state == STATE_CRLF) && (oneByte == '.')) {
     // Read <CR><LF><DOT> so this line needs an additional period.
     super.write('.');
     state = STATE_NORMAL;
   } else {
     state = STATE_NORMAL;
   }
   super.write(oneByte);
 }
Exemple #5
0
 public void write(int c) throws IOException {
   inbuf[i] = c;
   i++;
   if (i == 3) {
     super.write(toBase64[(inbuf[0] & 0xFC) >> 2]);
     super.write(toBase64[((inbuf[0] & 0x03) << 4) | ((inbuf[1] & 0xF0) >> 4)]);
     super.write(toBase64[((inbuf[1] & 0x0F) << 2) | ((inbuf[2] & 0xC0) >> 6)]);
     super.write(toBase64[inbuf[2] & 0x3F]);
     col += 4;
     i = 0;
     if (col >= 76) {
       super.write('\n');
       col = 0;
     }
   }
 }
 @Override
 public void write(int b) throws IOException {
   if (checkWithinLimits(1)) {
     super.write(b);
     count++;
   }
 }
 @Override
 public void write(byte[] b) throws IOException {
   if (checkWithinLimits(b.length)) {
     super.write(b);
     count += b.length;
   }
 }
 public void writeln() throws MessagingException {
   try {
     super.out.write(newline);
   } catch (Exception exception) {
     throw new MessagingException("IOException", exception);
   }
 }
  /**
   * Flushes this output stream, forcing any pending buffered output bytes to be written.
   *
   * @throws IOException if an I/O error occurs or this stream is already closed
   */
  public void flush() throws IOException {
    ensureOpen();

    // Finish decompressing and writing pending output data
    if (!inf.finished()) {
      try {
        while (!inf.finished() && !inf.needsInput()) {
          int n;

          // Decompress pending output data
          n = inf.inflate(buf, 0, buf.length);
          if (n < 1) {
            break;
          }

          // Write the uncompressed output data block
          out.write(buf, 0, n);
        }
        super.flush();
      } catch (DataFormatException ex) {
        // Improperly formatted compressed (ZIP) data
        String msg = ex.getMessage();
        if (msg == null) {
          msg = "Invalid ZLIB data format";
        }
        throw new ZipException(msg);
      }
    }
  }
 @Override
 public void write(byte[] b, int off, int len) throws IOException {
   if (checkWithinLimits(len)) {
     super.write(b, off, len);
     count += len;
   }
 }
Exemple #11
0
 @Override
 public void write(int b) throws IOException {
   if (XMLChar.isValid((char) b)) {
     super.write(b);
   } else {
     System.err.println("Removing invalid character while marshalling XML: " + (char) b);
   }
 }
  @Override
  public void write(int b) throws IOException {

    // System.out.println( "input: " + b );
    // System.out.println( "output: " + ( b + EncryptOutputStream.KEY ) );
    super.write(b + EncryptOutputStream.KEY);

    // System.out.println( "" );
  }
 @Override
 public void write(int b) throws IOException {
   position++;
   if (firstMismatchPosition == -1) {
     int read = is.read();
     if (b != read) firstMismatchPosition = position;
   }
   super.write(b);
 }
Exemple #14
0
 @Override
 public void write(int b) throws IOException {
   try {
     mSignature.update((byte) b);
   } catch (SignatureException e) {
     throw new IOException("SignatureException: " + e);
   }
   super.write(b);
   mCount++;
 }
 @Override
 public void write(byte[] b, int off, int len) throws IOException {
   if (firstMismatchPosition == -1) {
     for (int i = off; i < len; i++) {
       write(b[i]);
     }
   } else {
     super.write(b, off, len);
   }
 }
Exemple #16
0
 @Override
 public void write(byte[] b, int off, int len) throws IOException {
   try {
     mSignature.update(b, off, len);
   } catch (SignatureException e) {
     throw new IOException("SignatureException: " + e);
   }
   super.write(b, off, len);
   mCount += len;
 }
Exemple #17
0
    /**
     * Calls {@link #write(int)} repeatedly until <var>len</var> bytes are written.
     *
     * @param theBytes array from which to read bytes
     * @param off offset for array
     * @param len max number of bytes to read into array
     * @since 1.3
     */
    public void write(byte[] theBytes, int off, int len) throws java.io.IOException {
      // Encoding suspended?
      if (suspendEncoding) {
        super.out.write(theBytes, off, len);
        return;
      } // end if: supsended

      for (int i = 0; i < len; i++) {
        write(theBytes[off + i]);
      } // end for: each byte written
    } // end write
Exemple #18
0
    /**
     * Flushes and closes (I think, in the superclass) the stream.
     *
     * @since 1.3
     */
    public void close() throws java.io.IOException {
      // 1. Ensure that pending characters are written
      flushBase64();

      // 2. Actually close the stream
      // Base class both flushes and closes.
      super.close();

      buffer = null;
      out = null;
    } // end close
Exemple #19
0
 public void flush() throws IOException {
   if (i == 1) {
     super.write(toBase64[(inbuf[0] & 0xFC) >> 2]);
     super.write(toBase64[(inbuf[0] & 0x03) << 4]);
     super.write('=');
     super.write('=');
   } else if (i == 2) {
     super.write(toBase64[(inbuf[0] & 0xFC) >> 2]);
     super.write(toBase64[((inbuf[0] & 0x03) << 4) | ((inbuf[1] & 0xF0) >> 4)]);
     super.write(toBase64[(inbuf[1] & 0x0F) << 2]);
     super.write('=');
   }
   if (col > 0) {
     super.write('\n');
     col = 0;
   }
 }
 /**
  * End the current part.
  *
  * @exception IOException IOException
  */
 @Override
 public void close() throws IOException {
   try {
     if (inPart) out.write(__CRLF);
     out.write(__DASHDASH);
     out.write(boundaryBytes);
     out.write(__DASHDASH);
     out.write(__CRLF);
     inPart = false;
   } finally {
     super.close();
   }
 }
Exemple #21
0
 /**
  * Closes the stream, this MUST be called to ensure proper padding is written to the end of the
  * output stream.
  *
  * @exception IOException if an I/O error occurs
  */
 public void close() throws IOException {
   // Handle leftover bytes
   if (charCount % 3 == 1) { // one leftover
     int lookup = (carryOver << 4) & 63;
     out.write(chars[lookup]);
     out.write('=');
     out.write('=');
   } else if (charCount % 3 == 2) { // two leftovers
     int lookup = (carryOver << 2) & 63;
     out.write(chars[lookup]);
     out.write('=');
   }
   super.close();
 }
    @Override
    public void close() throws IOException {
      if (closed) {
        return;
      }
      closed = true;

      try {
        super.close();
        uploadObject();
      } finally {
        if (!tempFile.delete()) {
          log.warn("Could not delete temporary file: %s", tempFile);
        }
        // close transfer manager but keep underlying S3 client open
        transferManager.shutdownNow(false);
      }
    }
  /**
   * Closes this output stream and releases any system resources associated with this stream.
   *
   * <p>This method invokes the <code>doFinal</code> method of the encapsulated cipher object, which
   * causes any bytes buffered by the encapsulated cipher to be processed. The result is written out
   * by calling the <code>flush</code> method of this output stream.
   *
   * <p>This method resets the encapsulated cipher object to its initial state and calls the <code>
   * close</code> method of the underlying output stream.
   *
   * @exception java.io.IOException if an I/O error occurs.
   */
  public void close() throws IOException {
    try {
      if (bufferedBlockCipher != null) {
        byte[] buf = new byte[bufferedBlockCipher.getOutputSize(0)];

        int outLen = bufferedBlockCipher.doFinal(buf, 0);

        if (outLen != 0) {
          out.write(buf, 0, outLen);
        }
      }
    } catch (Exception e) {
      throw new IOException("Error closing stream: " + e.toString());
    }

    flush();

    super.close();
  }
Exemple #24
0
    /**
     * Writes the byte to the output stream after converting to/from Base64 notation. When encoding,
     * bytes are buffered three at a time before the output stream actually gets a write() call.
     * When decoding, bytes are buffered four at a time.
     *
     * @param theByte the byte to write
     * @since 1.3
     */
    public void write(int theByte) throws java.io.IOException {
      // Encoding suspended?
      if (suspendEncoding) {
        super.out.write(theByte);
        return;
      } // end if: supsended

      // Encode?
      if (encode) {
        buffer[position++] = (byte) theByte;
        if (position >= bufferLength) // Enough to encode.
        {
          out.write(encode3to4(b4, buffer, bufferLength));

          lineLength += 4;
          if (breakLines && lineLength >= MAX_LINE_LENGTH) {
            out.write(NEW_LINE);
            lineLength = 0;
          } // end if: end of line

          position = 0;
        } // end if: enough to output
      } // end if: encoding

      // Else, Decoding
      else {
        // Meaningful Base64 character?
        if (DECODABET[theByte & 0x7f] > WHITE_SPACE_ENC) {
          buffer[position++] = (byte) theByte;
          if (position >= bufferLength) // Enough to output.
          {
            int len = Base64.decode4to3(buffer, 0, b4, 0);
            out.write(b4, 0, len);
            // out.write( Base64.decode4to3( buffer ) );
            position = 0;
          } // end if: enough to output
        } // end if: meaningful base64 character
        else if (DECODABET[theByte & 0x7f] != WHITE_SPACE_ENC) {
          throw new java.io.IOException("Invalid character in Base64 data.");
        } // end else: not white space either
      } // end else: decoding
    } // end write
  /**
   * Writes a single byte value. <br>
   * If the method detects two adjacent '/' signs all data up until the next line feed or carriage
   * return is ignored, including the two '/' signs.
   *
   * @param b The data
   * @throws IOException
   */
  public void write(int b) throws IOException {
    for (int i = 1; i < databuffer.length; i++) {
      databuffer[i - 1] = databuffer[i];
    }

    databuffer[databuffer.length - 1] = b;

    if (databuffer[0] == NOT_VALID_DATA) return;

    if (databuffer[0] == CHAR_SLASH && databuffer[1] == CHAR_SLASH) {
      foundComment = true;
      return;
    }

    if (foundComment && (databuffer[0] == 10 || databuffer[0] == 13)) {
      foundComment = false;
      return;
    } else if (foundComment) return;

    super.write(databuffer[0]);
  }
 @Override
 public void write(byte[] b, int off, int len) throws IOException {
   super.write(b, off, len);
   transferred += len;
   fireProgress();
 }
Exemple #27
0
 @Override
 public void flush() throws IOException {
   super.flush();
   out2.flush();
 }
 /**
  * Flushes this output stream by forcing any buffered output bytes that have already been
  * processed by the encapsulated cipher object to be written out.
  *
  * <p>Any bytes buffered by the encapsulated cipher and waiting to be processed by it will not be
  * written out. For example, if the encapsulated cipher is a block cipher, and the total number of
  * bytes written using one of the <code>write</code> methods is less than the cipher's block size,
  * no bytes will be written out.
  *
  * @exception java.io.IOException if an I/O error occurs.
  */
 public void flush() throws IOException {
   super.flush();
 }
Exemple #29
0
 @Override
 public void write(int b) throws IOException {
   super.write(b);
   out2.write(b);
 }
 @Override
 public void write(int b) throws IOException {
   super.write(b);
   transferred++;
   fireProgress();
 }