예제 #1
0
 /**
  * Constructs a new {@code PushbackInputStream} with {@code in} as source
  * input stream. The size of the pushback buffer is set to {@code size}.
  *
  * @param in
  *            the source input stream.
  * @param size
  *            the size of the pushback buffer.
  * @throws IllegalArgumentException
  *             if {@code size} is negative.
  */
 public PushbackInputStream(InputStream inJ, int size)
     : base(inJ)
 {
     if (size <= 0) {
         throw new java.lang.IllegalArgumentException("size : "+size); //Messages.getString("luni.A3") $NON-NLS-1$
     }
     buf = (inJ == null) ? null : new byte[size];
     pos = size;
 }
예제 #2
0
 /**
  * Constructs a new SequenceInputStream using the elements returned from
  * Enumeration {@code e} as the stream sequence. The instances returned by
  * {@code e.nextElement()} must be of type {@link InputStream}.
  *
  * @param e
  *            the enumeration of {@code InputStreams} to get bytes from.
  * @throws NullPointerException
  *             if any of the elements in {@code e} is {@code null}.
  */
 public SequenceInputStream(java.util.Enumeration<InputStream> e)
 {
     this.e = e;
     if (e.hasMoreElements ()) {
         inJ = e.nextElement ();
         if (inJ == null) {
             throw new java.lang.NullPointerException ();
         }
     }
 }
예제 #3
0
 /**
  * Constructs a new {@code SequenceInputStream} using the two streams
  * {@code s1} and {@code s2} as the sequence of streams to read from.
  *
  * @param s1
  *            the first stream to get bytes from.
  * @param s2
  *            the second stream to get bytes from.
  * @throws NullPointerException
  *             if {@code s1} is {@code null}.
  */
 public SequenceInputStream(InputStream s1, InputStream s2)
 {
     if (s1 == null) {
         throw new java.lang.NullPointerException ();
     }
     java.util.Vector<InputStream> inVector = new java.util.Vector<InputStream> (1);
     inVector.addElement (s2);
     e = inVector.elements ();
     inJ = s1;
 }
예제 #4
0
 /**
  * Constructs a new {@code InputStreamReader} on the {@link InputStream}
  * {@code in}. This constructor sets the character converter to the encoding
  * specified in the "file.encoding" property and falls back to ISO 8859_1
  * (ISO-Latin-1) if the property doesn't exist.
  *
  * @param in
  *            the input stream from which to read characters.
  */
 public InputStreamReader(InputStream inJ)
     : base(inJ)
 {
     this.inJ = inJ;
     /*String encoding = AccessController
             .doPrivileged(new PriviAction<String>(
                     "file.encoding", "ISO8859_1")); //$NON-NLS-1$//$NON-NLS-2$*/
     String encoding = java.lang.SystemJ.getProperty("file.encoding", "ISO8859_1");
     decoder = java.nio.charset.Charset.forName(encoding).newDecoder().onMalformedInput(
             java.nio.charset.CodingErrorAction.REPLACE).onUnmappableCharacter(
             java.nio.charset.CodingErrorAction.REPLACE);
     bytes.limit(0);
 }
예제 #5
0
 /**
  * Closes this reader. This implementation closes the source InputStream and
  * releases all local storage.
  *
  * @throws IOException
  *             if an error occurs attempting to close this reader.
  */
 public override void close()
 {
     // throws IOException {
     lock (this.lockJ) {
         decoder = null;
         if (inJ != null) {
             inJ.close();
             inJ = null;
         }
     }
 }
예제 #6
0
 /**
  * Constructs a new InputStreamReader on the InputStream {@code in} and
  * Charset {@code charset}.
  *
  * @param in
  *            the source InputStream from which to read characters.
  * @param charset
  *            the Charset that defines the character converter
  */
 public InputStreamReader(InputStream inJ, java.nio.charset.Charset charset)
     : base(inJ)
 {
     this.inJ = inJ;
     decoder = charset.newDecoder().onMalformedInput(
             java.nio.charset.CodingErrorAction.REPLACE).onUnmappableCharacter(
             java.nio.charset.CodingErrorAction.REPLACE);
     bytes.limit(0);
 }
예제 #7
0
 /**
  * Constructs a new InputStreamReader on the InputStream {@code in} and
  * CharsetDecoder {@code dec}.
  *
  * @param in
  *            the source InputStream from which to read characters.
  * @param dec
  *            the CharsetDecoder used by the character conversion.
  */
 public InputStreamReader(InputStream inJ, java.nio.charset.CharsetDecoder dec)
     : base(inJ)
 {
     dec.averageCharsPerByte();
     this.inJ = inJ;
     decoder = dec;
     bytes.limit(0);
 }
예제 #8
0
 /**
  * Constructs a new {@code PushbackInputStream} with the specified input
  * stream as source. The size of the pushback buffer is set to the default
  * value of 1 byte.
  *
  * @param in
  *            the source input stream.
  */
 public PushbackInputStream(InputStream inJ)
     : base(inJ)
 {
     buf = (inJ == null) ? null : new byte[1];
     pos = 1;
 }
예제 #9
0
 public FilterInputStream(InputStream inJ)
 {
     this.inJ = inJ;
 }
예제 #10
0
 /**
  * Constructs a new {@code LineNumberInputStream} on the {@link InputStream}
  * {@code in}. Line numbers are counted for all data read from this stream.
  *
  * @param in
  *            The non-null input stream to count line numbers.
  */
 public LineNumberInputStream(InputStream inJ)
     : base(inJ)
 {
 }
예제 #11
0
 /**
  * Constructs a new {@code BufferedInputStream} on the {@link InputStream}
  * {@code in}. The default buffer size (8 KB) is allocated and all reads
  * can now be filtered through this stream.
  *
  * @param in
  *            the InputStream the buffer reads from.
  */
 public BufferedInputStream(InputStream inJ)
     : base(inJ)
 {
     buf = new byte[8192];
 }
예제 #12
0
 //throws IOException
 private int fillbuf(InputStream localIn, byte[] localBuf)
 {
     if (markpos == -1 || (pos - markpos >= marklimit)) {
         /* Mark position not set or exceeded readlimit */
         int result = localIn.read(localBuf);
         if (result > 0) {
             markpos = -1;
             pos = 0;
             count = result == -1 ? 0 : result;
         }
         return result;
     }
     if (markpos == 0 && marklimit > localBuf.Length) {
         /* Increase buffer size to accommodate the readlimit */
         int newLength = localBuf.Length * 2;
         if (newLength > marklimit) {
             newLength = marklimit;
         }
         byte[] newbuf = new byte[newLength];
         java.lang.SystemJ.arraycopy(localBuf, 0, newbuf, 0, localBuf.Length);
         // Reassign buf, which will invalidate any local references
         // FIXME: what if buf was null?
         localBuf = buf = newbuf;
     } else if (markpos > 0) {
         java.lang.SystemJ.arraycopy(localBuf, markpos, localBuf, 0, localBuf.Length
                 - markpos);
     }
     /* Set the new position and mark position */
     pos -= markpos;
     count = markpos = 0;
     int bytesread = localIn.read(localBuf, pos, localBuf.Length - pos);
     count = bytesread <= 0 ? pos : pos + bytesread;
     return bytesread;
 }
예제 #13
0
 /**
  * Constructs a new {@code BufferedInputStream} on the {@link InputStream}
  * {@code in}. The buffer size is specified by the parameter {@code size}
  * and all reads are now filtered through this stream.
  *
  * @param in
  *            the input stream the buffer reads from.
  * @param size
  *            the size of buffer to allocate.
  * @throws IllegalArgumentException
  *             if {@code size &lt; 0}.
  */
 public BufferedInputStream(InputStream inJ, int size)
     : base(inJ)
 {
     if (size <= 0) {
         // luni.A3=size must be > 0
         throw new java.lang.IllegalArgumentException("size must be > 0"); //$NON-NLS-1$
     }
     buf = new byte[size];
 }
예제 #14
0
 /**
  * Sets up the next InputStream or leaves it alone if there are none left.
  *
  * @throws IOException
  */
 private void nextStream()
 {
     // throws IOException {
     if (inJ != null) {
         inJ.close ();
     }
     if (e.hasMoreElements ()) {
         inJ = e.nextElement ();
         if (inJ == null) {
             throw new java.lang.NullPointerException ();
         }
     } else {
         inJ = null;
     }
 }
예제 #15
0
 public ObjectInputStream(InputStream input)
 {
     delegateInstance = input is DataInputStream ? (DataInputStream)input : new DataInputStream(input);
 }
예제 #16
0
 /**
  * Constructs a new InputStreamReader on the InputStream {@code in}. The
  * character converter that is used to decode bytes into characters is
  * identified by name by {@code enc}. If the encoding cannot be found, an
  * UnsupportedEncodingException error is thrown.
  *
  * @param in
  *            the InputStream from which to read characters.
  * @param enc
  *            identifies the character converter to use.
  * @throws NullPointerException
  *             if {@code enc} is {@code null}.
  * @throws UnsupportedEncodingException
  *             if the encoding specified by {@code enc} cannot be found.
  */
 public InputStreamReader(InputStream inJ, String enc)
     : base(inJ)
 {
     //throws UnsupportedEncodingException {
     if (enc == null) {
         throw new java.lang.NullPointerException();
     }
     this.inJ = inJ;
     try {
         decoder = java.nio.charset.Charset.forName(enc).newDecoder().onMalformedInput(
                 java.nio.charset.CodingErrorAction.REPLACE).onUnmappableCharacter(
                 java.nio.charset.CodingErrorAction.REPLACE);
     } catch (java.lang.IllegalArgumentException e) {
         throw (UnsupportedEncodingException)
                 new UnsupportedEncodingException(enc).initCause(e);
     }
     bytes.limit(0);
 }
예제 #17
0
 public StreamTokenizer(InputStream isJ)
     : this()
 {
     if (isJ == null) {
         throw new java.lang.NullPointerException();
     }
     inStream = isJ;
 }
예제 #18
0
 /**
  * Constructs a new DataInputStream on the InputStream {@code in}. All
  * reads are then filtered through this stream. Note that data read by this
  * stream is not in a human readable format and was most likely created by a
  * DataOutputStream.
  *
  * @param in
  *            the source InputStream the filter reads from.
  * @see DataOutputStream
  * @see RandomAccessFile
  */
 public DataInputStream(InputStream inJ)
     : base(inJ)
 {
     buff = new byte[8];
 }
예제 #19
0
 /*
  * Constructs a new DataInputStream on the InputStream {@code in}. All
  * reads are then filtered through this stream. Note that data read by this
  * stream is not in a human readable format and was most likely created by a
  * DataOutputStream.
  *
  * @param in
  *            the source InputStream the filter reads from.
  * @see DataOutputStream
  * @see RandomAccessFile
  */
 public DataInputStream(InputStream inJ) : base(inJ)
 {
     buff = new byte[8];
 }