/// <summary> /// Flushes this output stream and forces any buffered output bytes /// to be written out. /// </summary> /// <exception cref="java.io.IOException"> /// If an I/O error occurs. /// </exception> public override void flush() { try { m_stream.Flush(); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Writes <c>length</c> bytes from the specified byte array /// starting at <c>offset</c> to this output stream. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name="offset">The offset.</param> /// <param name="length">The length.</param> /// <remarks> /// The general contract is that some of the bytes in the array /// <code>buffer</code> are written to the output stream in order; /// element <code>buffer[offset]</code> is the first byte written /// and <code>buffer[offset+length-1]</code> is the last byte written /// by this operation. /// </remarks> /// <exception cref="java.io.IOException"> /// If an I/O error occurs. In particular, an exception is thrown /// if the output stream is closed. /// </exception> public override void write(byte[] buffer, int offset, int length) { try { m_stream.Write(buffer, offset, length); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Writes the specified byte to this output stream. /// </summary> /// <param name="b">The <c>byte</c>.</param> /// <remarks> /// The general contract for <c>write</c> is that one /// byte is written to the output stream. The byte to be /// written is the eight low-order bits of the argument /// <c>b</c>. The 24 high-order bits of <c>b</c> /// are ignored. /// </remarks> /// <exception cref="Exception"> /// If an I/O error occurs. In particular, an /// <code>IOException</code> may be thrown if the /// output stream has been closed. /// </exception> public override void write(int b) { try { m_stream.WriteByte((byte)(b & 0xff)); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Reads the next byte of data from this input stream. /// </summary> /// <remarks> /// The byte value is returned as an <c>int</c> in /// the range <c>0</c> to <c>255</c>. If no byte /// is available because the end of the stream has been reached, /// the value <c>-1</c> is returned. This method blocks /// until input data is available, the end of the stream is /// detected, or an exception is thrown. /// </remarks> /// <returns> /// The next byte of data, or <c>-1</c> if the end of the /// stream is reached. /// </returns> /// <exception cref="java.io.IOException"> /// if an I/O error occurs. /// </exception> public override int read() { try { return(m_stream.ReadByte()); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Returns an estimate of the number of bytes that can be read (or /// skipped over) from this input stream without blocking by the next /// invocation of a method for this input stream. The next invocation /// might be the same thread or another thread. A single read or skip of this /// many bytes will not block, but may read or skip fewer bytes. /// </summary> /// <remarks> /// <para> Note that while some implementations of {@code InputStream} will return /// the total number of bytes in the stream, many will not. It is /// never correct to use the return value of this method to allocate /// a buffer intended to hold all data in this stream. /// </para> /// <para> A subclass' implementation of this method may choose to throw a /// java.io.IOException if this input stream has been closed by /// invoking the close() method. /// </para> /// <para> The <c>available</c> method of the java.io.InputStream class always /// returns {@code 0}. /// </para> /// <para> This method should be overridden by subclasses. /// </para> /// </remarks> /// <returns> /// an estimate of the number of bytes that can be read (or skipped /// over) from this input stream without blocking or {@code 0} when /// it reaches the end of the input stream. /// </returns> /// <exception cref="java.io.IOException">if an I/O error occurs.</exception> public override int available() { try { checked { return((m_stream.CanRead && m_stream.CanSeek) ? (int)(m_stream.Length - m_stream.Position) : base.available()); } } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Reads up to <c>length</c> bytes of data from the input/ stream /// into an array of bytes. /// </summary> /// <remarks> /// <para> /// An attempt is made to read as many as <c>length</c> bytes, but /// a smaller number may be read. The number of bytes actually /// read is returned as an integer. /// </para> /// <para> /// This method blocks until input data is available, end of file /// is detected, or an exception is thrown. /// </para> /// <para> /// If <c>length</c> is zero, then no bytes are read and <c>0</c> is /// returned; otherwise, there is an attempt to read at least one byte. /// If no byte is available because the stream is at end of file, the /// value <c>-1</c> is returned; otherwise, at least one byte is read /// and stored into <c>buffer</c>. /// </para> /// <para> /// The first byte read is stored into element <c>buffer[offset]</c>, /// the next one into <c>buffer[offset+1]</c>, and so on. The number /// of bytes read is, at most, equal to <c>length</c>. Let <i>k</i> /// be the number of bytes actually read; these bytes will be stored /// in elements <c>buffer[offset]</c> through <c>buffer[offset+</c> /// <i>k</i><c>-1]</c>, leaving elements <c>buffer[offset+</c><i>k</i> /// <c>]</c> through <c>buffer[offset+length-1]</c> unaffected. /// </para> /// <para> /// In every case, elements <c>buffer[0]</c> through /// <c>buffer[offset]</c> and elements <c>buffer[offset+length]</c> /// through <c>buffer[b.length-1]</c> are unaffected. /// </para> /// </remarks> /// <param name="buffer"> /// The buffer into which the data is read. /// </param> /// <param name="offset"> /// The start offset in array <c>buffer</c> at which the data /// is written. /// </param> /// <param name="length"> /// The maximum number of bytes to read. /// </param> /// <returns> /// The total number of bytes read into the buffer, or <c>-1</c> if /// there is no more data because the end of the stream has been /// reached. /// </returns> /// <exception cref="java.io.IOException"> /// If the first byte cannot be read for any reason other than end of /// file, or if the input stream has been closed, or if some other /// I/O error occurs. /// </exception> /// <exception cref="java.lang.NullPointerException"> /// If <c>buffer</c> is <c>null</c>. /// </exception> /// <exception cref="java.lang.IndexOutOfBoundsException"> /// If <c>offset</c> is negative, <c>length</c> is negative, /// or <c>length</c> is greater than <c>b.length - offset</c>. /// </exception> public override int read( byte[] buffer, int offset, int length) { try { int bytesRead = m_stream.Read(buffer, offset, length); return((bytesRead == 0) ? -1 : bytesRead); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Reads up to <c>length</c> bytes of data from the input/ stream /// into an array of bytes. /// </summary> /// <remarks> /// <para> /// An attempt is made to read as many as <c>length</c> bytes, but /// a smaller number may be read. The number of bytes actually /// read is returned as an integer. /// </para> /// <para> /// This method blocks until input data is available, end of file /// is detected, or an exception is thrown. /// </para> /// <para> /// If <c>length</c> is zero, then no bytes are read and <c>0</c> is /// returned; otherwise, there is an attempt to read at least one byte. /// If no byte is available because the stream is at end of file, the /// value <c>-1</c> is returned; otherwise, at least one byte is read /// and stored into <c>buffer</c>. /// </para> /// <para> /// The first byte read is stored into element <c>buffer[offset]</c>, /// the next one into <c>buffer[offset+1]</c>, and so on. The number /// of bytes read is, at most, equal to <c>length</c>. Let <i>k</i> /// be the number of bytes actually read; these bytes will be stored /// in elements <c>buffer[offset]</c> through <c>buffer[offset+</c> /// <i>k</i><c>-1]</c>, leaving elements <c>buffer[offset+</c><i>k</i> /// <c>]</c> through <c>buffer[offset+length-1]</c> unaffected. /// </para> /// <para> /// In every case, elements <c>buffer[0]</c> through /// <c>buffer[offset]</c> and elements <c>buffer[offset+length]</c> /// through <c>buffer[b.length-1]</c> are unaffected. /// </para> /// </remarks> /// <param name="buffer"> /// The buffer into which the data is read. /// </param> /// <param name="offset"> /// The start offset in array <c>buffer</c> at which the data /// is written. /// </param> /// <param name="length"> /// The maximum number of bytes to read. /// </param> /// <returns> /// The total number of bytes read into the buffer, or <c>-1</c> if /// there is no more data because the end of the stream has been /// reached. /// </returns> /// <exception cref="java.io.IOException"> /// If the first byte cannot be read for any reason other than end of /// file, or if the input stream has been closed, or if some other /// I/O error occurs. /// </exception> /// <exception cref="java.lang.NullPointerException"> /// If <c>buffer</c> is <c>null</c>. /// </exception> /// <exception cref="java.lang.IndexOutOfBoundsException"> /// If <c>offset</c> is negative, <c>length</c> is negative, /// or <c>length</c> is greater than <c>b.length - offset</c>. /// </exception> public override int read( byte[] buffer, int offset, int length) { try { int bytesRead = m_stream.Read(buffer, offset, length); return (bytesRead == 0) ? -1 : bytesRead; } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Reads the next byte of data from this input stream. /// </summary> /// <remarks> /// The byte value is returned as an <c>int</c> in /// the range <c>0</c> to <c>255</c>. If no byte /// is available because the end of the stream has been reached, /// the value <c>-1</c> is returned. This method blocks /// until input data is available, the end of the stream is /// detected, or an exception is thrown. /// </remarks> /// <returns> /// The next byte of data, or <c>-1</c> if the end of the /// stream is reached. /// </returns> /// <exception cref="java.io.IOException"> /// if an I/O error occurs. /// </exception> public override int read() { try { return m_stream.ReadByte(); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Closes this input stream and releases any system /// resources associated with it. /// </summary> /// <exception cref="Exception"> /// If an I/O error occurs. /// </exception> public override void close() { try { m_stream.Close(); } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }
/// <summary> /// Returns an estimate of the number of bytes that can be read (or /// skipped over) from this input stream without blocking by the next /// invocation of a method for this input stream. The next invocation /// might be the same thread or another thread. A single read or skip of this /// many bytes will not block, but may read or skip fewer bytes. /// </summary> /// <remarks> /// <para> Note that while some implementations of {@code InputStream} will return /// the total number of bytes in the stream, many will not. It is /// never correct to use the return value of this method to allocate /// a buffer intended to hold all data in this stream. /// </para> /// <para> A subclass' implementation of this method may choose to throw a /// java.io.IOException if this input stream has been closed by /// invoking the close() method. /// </para> /// <para> The <c>available</c> method of the java.io.InputStream class always /// returns {@code 0}. /// </para> /// <para> This method should be overridden by subclasses. /// </para> /// </remarks> /// <returns> /// an estimate of the number of bytes that can be read (or skipped /// over) from this input stream without blocking or {@code 0} when /// it reaches the end of the input stream. /// </returns> /// <exception cref="java.io.IOException">if an I/O error occurs.</exception> public override int available() { try { checked { return (m_stream.CanRead && m_stream.CanSeek) ? (int)(m_stream.Length - m_stream.Position) : base.available(); } } catch (Exception ex) { IOException ioe = new IOException(ex.Message); ioe.initCause(ex); throw ioe; } }