java.io

Class PushbackInputStream

Implemented Interfaces:
Closeable
Known Direct Subclasses:
FromNetASCIIInputStream

public class PushbackInputStream
extends FilterInputStream

A PushbackInputStream adds functionality to another input stream, namely the ability to "push back" or "unread" one byte. This is useful in situations where it is convenient for a fragment of code to read an indefinite number of data bytes that are delimited by a particular byte value; after reading the terminating byte, the code fragment can "unread" it, so that the next read operation on the input stream will reread the byte that was pushed back. For example, bytes representing the characters constituting an identifier might be terminated by a byte representing an operator character; a method whose job is to read just an identifier can read until it sees the operator and then push the operator back to be re-read.
Since:
JDK1.0

Field Summary

protected byte[]
buf
The pushback buffer.
protected int
pos
The position within the pushback buffer from which the next byte will be read.

Fields inherited from class java.io.FilterInputStream

in

Constructor Summary

PushbackInputStream(InputStream in)
Creates a PushbackInputStream and saves its argument, the input stream in, for later use.
PushbackInputStream(InputStream in, int size)
Creates a PushbackInputStream with a pushback buffer of the specified size, and saves its argument, the input stream in, for later use.

Method Summary

int
available()
Returns the number of bytes that can be read from this input stream without blocking.
void
close()
Closes this input stream and releases any system resources associated with the stream.
void
mark(int readlimit)
Marks the current position in this input stream.
boolean
markSupported()
Tests if this input stream supports the mark and reset methods, which it does not.
int
read()
Reads the next byte of data from this input stream.
int
read(byte[] b, int off, int len)
Reads up to len bytes of data from this input stream into an array of bytes.
void
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream.
long
skip(long n)
Skips over and discards n bytes of data from this input stream.
void
unread(byte[] b)
Pushes back an array of bytes by copying it to the front of the pushback buffer.
void
unread(byte[] b, int off, int len)
Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer.
void
unread(int b)
Pushes back a byte by copying it to the front of the pushback buffer.

Methods inherited from class java.io.FilterInputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.io.InputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buf

protected byte[] buf
The pushback buffer.
Since:
JDK1.1

pos

protected int pos
The position within the pushback buffer from which the next byte will be read. When the buffer is empty, pos is equal to buf.length; when the buffer is full, pos is equal to zero.
Since:
JDK1.1

Constructor Details

PushbackInputStream

public PushbackInputStream(InputStream in)
Creates a PushbackInputStream and saves its argument, the input stream in, for later use. Initially, there is no pushed-back byte (the field pushBack is initialized to -1).
Parameters:
in - the input stream from which bytes will be read.
Usages and Demos :

View More Examples of PushbackInputStream(InputStream in)
   1:                     if (!(in instanceof PushbackInputStream)) {
   2:                         in = new PushbackInputStream(in);
   3:                     }
   4:                     ((PushbackInputStream) in).unread(c2);
   5:                 } else {

View Full Code Here
   1:             Vector vec = new Vector();
   2:             PushbackInputStream pushin = new PushbackInputStream(System.in);
   3:             boolean eof;
   4:             while (true) 
   5:             {    

View Full Code Here
   1:                       if (!(in instanceof PushbackInputStream)) {
   2:                          in = new PushbackInputStream(in);
   3:                       }
   4:                       ((PushbackInputStream)in).unread(c2);
   5:                     } else {

View Full Code Here
   1:             if (!(in instanceof PushbackInputStream))
   2:             in = this.in = new PushbackInputStream(in);
   3:             ((PushbackInputStream)in).unread(c2);
   4:         }
   5:         }

View Full Code Here
   1:                         if (!(in instanceof PushbackInputStream)) {
   2:                             in = new PushbackInputStream(in);
   3:                         }
   4:                         ((PushbackInputStream) in).unread(c2);
   5:                     } else {

View Full Code Here

PushbackInputStream

public PushbackInputStream(InputStream in,
                           int size)
Creates a PushbackInputStream with a pushback buffer of the specified size, and saves its argument, the input stream in, for later use. Initially, there is no pushed-back byte (the field pushBack is initialized to -1).
Parameters:
in - the input stream from which bytes will be read.
size - the size of the pushback buffer.
Throws:
IllegalArgumentException - if size is <= 0
Since:
JDK1.1
Usages and Demos :

View More Examples of PushbackInputStream(InputStream in,int size)
   1:     {
   2:         super(new PushbackInputStream(inputStream, 1));
   3:         pushbackStream = (PushbackInputStream)in;
   4:         this.chunkSize = chunkSize;
   5:     }

View Full Code Here
   1:         if (encoding == null) {
   2:           PushbackInputStream pb = new PushbackInputStream(in, 2);
   3:           encoding = detectEncoding(pb);
   4:           in = pb;
   5:         }

View Full Code Here
   1:         if (encoding == null) {
   2:           PushbackInputStream pb = new PushbackInputStream(in, 2);
   3:           encoding = detectEncoding(pb);
   4:           in = pb;
   5:         }

View Full Code Here
   1:         throws IOException {
   2:         PushbackInputStream pbis = new PushbackInputStream(is, 128);
   3:         byte[] buf = new byte[4];
   4: 
   5:         int len = pbis.read(buf);

View Full Code Here
   1:     public ConfigurationData readConfigurationData(InputStream in) throws IOException, ClassNotFoundException {
   2:         PushbackInputStream pushbackInputStream = new PushbackInputStream(in, 2);
   3:         byte[] streamHeader = new byte[2];
   4:         if (pushbackInputStream.read(streamHeader) != 2) throw new AssertionError("Cound not read stream header");
   5:         pushbackInputStream.unread(streamHeader);

View Full Code Here

Method Details

available

public int available()
            throws IOException
Returns the number of bytes that can be read from this input stream without blocking. This method calls the available method of the underlying input stream; it returns that value plus the number of bytes that have been pushed back.
Overrides:
available in interface FilterInputStream
Returns:
the number of bytes that can be read from the input stream without blocking.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of available()
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5: 
   6: public final class FromNetASCIIInputStream extends PushbackInputStream
   7: {
   8:         ...
   9:     {
  10:         return (buf.length - pos) + in.available();
  11:     }

View Full Code Here
   1: import java.io.FileInputStream;
   2: import java.io.PushbackInputStream;
   3: import java.io.IOException;
   4:         ...
   5:     FileInputStream     in  = new FileInputStream(fileName);
   6:     PushbackInputStream pbi = new PushbackInputStream(in);
   7: 
   8:         ...
   9:     if(c == 's') {
  10:         int    l   = pbi.available();
  11:         byte[] buf = new byte[l];

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.zip.CRC32;
   4:         ...
   5: {
   6:   private PushbackInputStream _in;
   7:   private Inflater _inflater;
   8:         ...
   9:   {
  10:     _in = new PushbackInputStream(in, size);
  11: 
  12:         ...
  13:     if (!_isGzip)
  14:       return _in.available();

View Full Code Here

close

public void close()
            throws IOException
Closes this input stream and releases any system resources associated with the stream.
Specified by:
close in interface Closeable
Overrides:
close in interface FilterInputStream
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of close()
   1: 
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 9);
   7:             BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(file_fixed), 5096000);
   8:         ...
   9: 
  10:             in.close();
  11:             out.flush();
  12:         ...
  13:             out.close();

View Full Code Here
   1: 
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream());
   7:             BufferedOutputStream out_1 = new BufferedOutputStream( new FileOutputStream(strippedfile_video), 5120000);
   8:         ...
   9:             out_1.flush();
  10:             out_1.close();
  11:             out_2.flush();
  12:         ...
  13:             out_2.close();

View Full Code Here
   1: public class UnicodeInputStream extends InputStream {
   2:    PushbackInputStream internalIn;
   3:    boolean             isInited = false;
   4:         ...
   5:    public UnicodeInputStream(InputStream in, String defaultEnc) {
   6:        internalIn = new PushbackInputStream(in, BOM_SIZE);
   7:        this.defaultEnc = defaultEnc;
   8:         ...
   9:   public void close() throws IOException {
  10:      internalIn.close();
  11:   }

View Full Code Here
   1: 
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 8);
   7:             BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(temp_file), 5096000);
   8:         ...
   9: 
  10:             in.close();
  11:             out.flush();
  12:         ...
  13:             out.close();

View Full Code Here
   1: import java.util.Hashtable;
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedInputStream;
   4:         ...
   5:             URLConnection uc = Access.getAccess ().openConnection (robotstxtURL);
   6:             PushbackInputStream in = new PushbackInputStream (new BufferedInputStream (uc.getInputStream ()));
   7: 
   8:         ...
   9: 
  10:             in.close();

View Full Code Here

mark

public void mark(int readlimit)
Marks the current position in this input stream.

The mark method of PushbackInputStream does nothing.

Overrides:
mark in interface FilterInputStream
Parameters:
readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
Usages and Demos :

View More Examples of mark(int readlimit)
   1:     
   2:     public void read(PushbackInputStream a_istr) throws BaseException
   3:     {
   4:         ...
   5:         {
   6:             a_istr.mark(1000);
   7:             String str = Parser.getNextToken(a_istr);
   8:             try {
   9:                 a_istr.reset();

View Full Code Here
   1:     
   2:     public void read(PushbackInputStream a_istr) throws BaseException
   3:     {
   4:         ...
   5:         {
   6:             a_istr.mark(1000);
   7:             String str = Parser.getNextToken(a_istr);
   8:             if(str.compareTo(CorbaValue.s_seqEnd) == 0)
   9:                 break;

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.Enumeration;
   4:         ...
   5:             InputStream is = (InputStream) (request.getAttribute(STREAM_ATTR));
   6:             PushbackInputStream pis = new PushbackInputStream(is, bufferSize);
   7:         ...
   8:             pis.mark(bufferSize);
   9:             docType = MCRUtils.parseDocumentType(pis);

View Full Code Here

markSupported

public boolean markSupported()
Tests if this input stream supports the mark and reset methods, which it does not.
Overrides:
markSupported in interface FilterInputStream
Returns:
false, since this class does not support the mark and reset methods.

read

public int read()
            throws IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method returns the most recently pushed-back byte, if there is one, and otherwise calls the read method of its underlying input stream and returns whatever value that method returns.

Overrides:
read in interface FilterInputStream
Returns:
the next byte of data, or -1 if the end of the stream has been reached.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of read()
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5: 
   6:     PushbackInputStream inStream;
   7: 
   8:         ...
   9: 
  10:     public MimeBodyPartInputStream(PushbackInputStream inStreamParam, byte[] boundaryParam) {
  11:         super();
  12:         ...
  13: 
  14:         int value = inStream.read();

View Full Code Here
   1: public class UnicodeInputStream extends InputStream {
   2:    PushbackInputStream internalIn;
   3:    boolean             isInited = false;
   4:         ...
   5:    public UnicodeInputStream(InputStream in, String defaultEnc) {
   6:        internalIn = new PushbackInputStream(in, BOM_SIZE);
   7:        this.defaultEnc = defaultEnc;
   8:         ...
   9:   public int read() throws IOException {
  10:      return internalIn.read();
  11:   }

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.Enumeration;
   4:         ...
   5:     
   6:     private PushbackInputStream stream;
   7: 
   8:         ...
   9:             boundary = "--" + contentType.substring(i + len, end);
  10:             stream = new PushbackInputStream(input, boundary.length());
  11:             if (!readTillFirstBoundary(stream, boundary.getBytes())) {
  12:         ...
  13:         
  14:         int v = stream.read();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5: 
   6:     private PushbackInputStream in;
   7: 
   8:         ...
   9:     int get() throws IOException {
  10:         int c = in.read();
  11: 
  12:         ...
  13:     int peek() throws IOException {
  14:         int lookaheadChar = in.read();

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.Collections;
   4:         ...
   5:             byte[] currentEOL = null;
   6:             while ((r = is.read()) >= 0) {
   7:                 if (r == '\n') {
   8:         ...
   9:                     currentEOL = CR;
  10:                     r = is.read();
  11:                     if (r == '\n') {
  12:         ...
  13:         }
  14:         PushbackInputStream in = new PushbackInputStream(src, 2048);

View Full Code Here

read

public int read(byte[] b,
                int off,
                int len)
            throws IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method first reads any pushed-back bytes; after that, if fewer than len bytes have been read then it reads from the underlying input stream. This method blocks until at least 1 byte of input is available.
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
IOException - if an I/O error occurs.
See Also:
java.io.InputStream.read(byte[], int, int)
Usages and Demos :

View More Examples of read(byte[] b,int off,int len)
   1: 
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 9);
   7:             BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(file_fixed), 5096000);
   8:         ...
   9:             {
  10:                 ret = in.read(header, 0, 9);
  11: 
  12:         ...
  13:                 data = new byte[len - 3];
  14:                 in.read(data, 0 , data.length);

View Full Code Here
   1: 
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream());
   7:             BufferedOutputStream out_1 = new BufferedOutputStream( new FileOutputStream(strippedfile_video), 5120000);
   8:         ...
   9:                 if (ret < array.length)
  10:                     in.read(array, ret, array.length - ret);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.zip.CRC32;
   4:         ...
   5: {
   6:   private PushbackInputStream _in;
   7:   private Inflater _inflater;
   8:         ...
   9:   {
  10:     _in = new PushbackInputStream(in, size);
  11: 
  12:         ...
  13:     if (! _isGzip)
  14:       return _in.read(b, off, len);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: import java.io.RandomAccessFile;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 20);
   7: 
   8:         ...
   9: 
  10:                 in.read(parser, 0, parserlength);
  11: 
  12:         ...
  13: 
  14:                 in.read(packet, 0, packetlength);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: import java.io.RandomAccessFile;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 65536);
   7: 
   8:         ...
   9: 
  10:                 in.read(parse12, 0, 12);

View Full Code Here

reset

public void reset()
            throws IOException
Repositions this stream to the position at the time the mark method was last called on this input stream.

The method reset for class PushbackInputStream does nothing except throw an IOException.

Overrides:
reset in interface FilterInputStream
Throws:
IOException - if this method is invoked.
Usages and Demos :

View More Examples of reset()
   1:     
   2:     public void read(PushbackInputStream a_istr) throws BaseException
   3:     {
   4:         ...
   5:             try {
   6:                 a_istr.reset();
   7:             } catch (IOException excp) { }
   8:             if(str.compareTo(CorbaValue.s_seqEnd) == 0)
   9:                 break;

View Full Code Here
   1:     
   2:     public void read(PushbackInputStream a_istr) throws BaseException
   3:     {
   4:         ...
   5:             try {
   6:                 a_istr.reset();
   7:             } catch (IOException excp) { }
   8:             CorbaValue v = m_def.elementType().createEmptyValue();
   9:             v.read(a_istr);

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.Enumeration;
   4:         ...
   5:             InputStream is = (InputStream) (request.getAttribute(STREAM_ATTR));
   6:             PushbackInputStream pis = new PushbackInputStream(is, bufferSize);
   7:             pis.mark(bufferSize);
   8:         ...
   9:             docType = MCRUtils.parseDocumentType(pis);
  10:             pis.reset();
  11:             sourceXML = new StreamSource(pis);

View Full Code Here

skip

public long skip(long n)
            throws IOException
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly zero. If n is negative, no bytes are skipped.

The skip method of PushbackInputStream first skips over the bytes in the pushback buffer, if any. It then calls the skip method of the underlying input stream if more bytes need to be skipped. The actual number of bytes skipped is returned.

Overrides:
skip in interface FilterInputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.
Since:
1.2
See Also:
FilterInputStream.in, java.io.InputStream.skip(long n)
Usages and Demos :

View More Examples of skip(long n)
   1: 
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 8);
   7:             BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(temp_file), 5096000);
   8:         ...
   9: 
  10:                     in.skip(0x1800 - len - 8);
  11:                 }

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: import java.util.zip.CRC32;
   4:         ...
   5: {
   6:   private PushbackInputStream _in;
   7:   private Inflater _inflater;
   8:         ...
   9:   {
  10:     _in = new PushbackInputStream(in, size);
  11: 
  12:         ...
  13:       length = (((int)_tbuffer[1]) << 4) | _tbuffer[0];
  14:       _in.skip(length);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: import java.io.FileOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(aXInputFile.getInputStream(), pes_packet.length);
   7: 
   8:         ...
   9:                             {
  10:                                 in.skip(6);
  11:                                 count += 12;
  12:         ...
  13: 
  14:                             in.skip(pes_payloadlength);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: import java.io.FileOutputStream;
   4:         ...
   5: 
   6:             PushbackInputStream in = new PushbackInputStream(aXInputFile.getInputStream(startPoint - base), pes_packet.length);
   7: 
   8:         ...
   9:                             {
  10:                                 in.skip(pes_packetoffset);
  11:                                 count += 12;
  12:         ...
  13: 
  14:                             in.skip(pes_payloadlength);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: import java.io.RandomAccessFile;
   4:         ...
   5: 
   6:                 PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream(), 94);
   7:                 BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(ttxfile), 655350);
   8:         ...
   9:                 while (count < startPoint)
  10:                     count += in.skip(startPoint-count);
  11: 
  12:         ...
  13:                     {
  14:                         in.skip(0x5C - 48);

View Full Code Here

unread

public void unread(byte[] b)
            throws IOException
Pushes back an array of bytes by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value b[0], the byte after that will have the value b[1], and so forth.
Parameters:
b - the byte array to push back
Throws:
IOException - If there is not enough room in the pushback buffer for the specified number of bytes.
Since:
JDK1.1
Usages and Demos :

View More Examples of unread(byte[] b)
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5:     private long totalRead;
   6:     private PushbackInputStream pushbackStream;
   7: 
   8:         ...
   9:     {
  10:         super(new PushbackInputStream(inputStream, 1));
  11:         pushbackStream = (PushbackInputStream)in;
  12:         ...
  13:         boolean hasMore = b >= 0;
  14:         pushbackStream.unread(b);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5: 
   6:     PushbackInputStream inStream;
   7: 
   8:         ...
   9: 
  10:     public MimeBodyPartInputStream(PushbackInputStream inStreamParam, byte[] boundaryParam) {
  11:         super();
  12:         ...
  13:             if (value != 10) {
  14:                 inStream.unread(value);

View Full Code Here
   1:         ByteArrayInputStream baInStream = new ByteArrayInputStream( data );
   2:         PushbackInputStream inStream = new PushbackInputStream( 
   3:             baInStream );
   4:         ...
   5:                 {
   6:                     inStream.unread(b);
   7:                     parseGGEPBlock( inStream );
   8:         ...
   9: 
  10:     private void parseGGEPBlock( PushbackInputStream inStream )
  11:     {

View Full Code Here
   1: import java.io.FileInputStream;
   2: import java.io.PushbackInputStream;
   3: import java.io.IOException;
   4:         ...
   5:     FileInputStream     in  = new FileInputStream(fileName);
   6:     PushbackInputStream pbi = new PushbackInputStream(in);
   7: 
   8:         ...
   9:     int c = pbi.read();
  10:     pbi.unread(c);

View Full Code Here
   1: import java.util.Hashtable;
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedInputStream;
   4:         ...
   5:             URLConnection uc = Access.getAccess ().openConnection (robotstxtURL);
   6:             PushbackInputStream in = new PushbackInputStream (new BufferedInputStream (uc.getInputStream ()));
   7: 
   8:         ...
   9:             else if (saw_eoln) {
  10:                 in.unread(c);
  11:                 break;

View Full Code Here

unread

public void unread(byte[] b,
                   int off,
                   int len)
            throws IOException
Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value b[off], the byte after that will have the value b[off+1], and so forth.
Parameters:
b - the byte array to push back.
off - the start offset of the data.
len - the number of bytes to push back.
Throws:
IOException - If there is not enough room in the pushback buffer for the specified number of bytes.
Since:
JDK1.1
Usages and Demos :

View More Examples of unread(byte[] b,int off,int len)
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5:   {
   6:     super (new PushbackInputStream (in, size));
   7:     this.name = name;
   8:         ...
   9:   {
  10:     PushbackInputStream p = (PushbackInputStream) in;
  11:     byte[] buffer = new byte[DETECT_BUFFER_SIZE];
  12:         ...
  13:       {
  14:         p.unread(buffer, 0, len);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5: 
   6:     PushbackInputStream inStream;
   7: 
   8:         ...
   9: 
  10:     public MimeBodyPartInputStream(PushbackInputStream inStreamParam, byte[] boundaryParam) {
  11:         super();
  12:         ...
  13:         if (needUnread0d0a) {
  14:             inStream.unread(boundary, 0, boundaryIndex);

View Full Code Here
   1: import java.io.InputStreamReader;
   2: import java.io.PushbackInputStream;
   3: import java.io.Reader;
   4:         ...
   5: 
   6:     PushbackInputStream pushbackStream = new PushbackInputStream(in, BOM_SIZE);
   7:     n = pushbackStream.read(bom, 0, bom.length);
   8:         ...
   9:     } else if (unread < -1) {
  10:       pushbackStream.unread(bom, 0, 0);
  11:     }

View Full Code Here
   1: public class SSHVersionSpySocket extends Socket {
   2:     PushbackInputStream pbIn;
   3:     Socket              origSocket;
   4:         ...
   5:     this.origSocket = origSocket;
   6:     pbIn = new PushbackInputStream(origSocket.getInputStream(), 256);
   7:     }
   8:         ...
   9: 
  10:     pbIn.unread(buf, 0, len);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: import java.io.Reader;
   4:         ...
   5:         throws IOException {
   6:         PushbackInputStream pbis = new PushbackInputStream(is, 128);
   7:         byte[] buf = new byte[4];
   8:         ...
   9:         if (len > 0) {
  10:             pbis.unread(buf, 0, len);
  11:         }

View Full Code Here

unread

public void unread(int b)
            throws IOException
Pushes back a byte by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value (byte)b.
Parameters:
b - the int value whose low-order byte is to be pushed back.
Throws:
IOException - If there is not enough room in the pushback buffer for the byte.
Usages and Demos :

View More Examples of unread(int b)
   1: import java.io.IOException;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5:     private long totalRead;
   6:     private PushbackInputStream pushbackStream;
   7: 
   8:         ...
   9:     {
  10:         super(new PushbackInputStream(inputStream, 1));
  11:         pushbackStream = (PushbackInputStream)in;
  12:         ...
  13:         boolean hasMore = b >= 0;
  14:         pushbackStream.unread(b);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.PushbackInputStream;
   3: 
   4:         ...
   5: 
   6:     PushbackInputStream inStream;
   7: 
   8:         ...
   9: 
  10:     public MimeBodyPartInputStream(PushbackInputStream inStreamParam, byte[] boundaryParam) {
  11:         super();
  12:         ...
  13:             if (value != 10) {
  14:                 inStream.unread(value);

View Full Code Here
   1:         ByteArrayInputStream baInStream = new ByteArrayInputStream( data );
   2:         PushbackInputStream inStream = new PushbackInputStream( 
   3:             baInStream );
   4:         ...
   5:                 {
   6:                     inStream.unread(b);
   7:                     parseGGEPBlock( inStream );
   8:         ...
   9: 
  10:     private void parseGGEPBlock( PushbackInputStream inStream )
  11:     {

View Full Code Here
   1: import java.io.FileInputStream;
   2: import java.io.PushbackInputStream;
   3: import java.io.IOException;
   4:         ...
   5:     FileInputStream     in  = new FileInputStream(fileName);
   6:     PushbackInputStream pbi = new PushbackInputStream(in);
   7: 
   8:         ...
   9:     int c = pbi.read();
  10:     pbi.unread(c);

View Full Code Here
   1: import java.util.Hashtable;
   2: import java.io.PushbackInputStream;
   3: import java.io.BufferedInputStream;
   4:         ...
   5:             URLConnection uc = Access.getAccess ().openConnection (robotstxtURL);
   6:             PushbackInputStream in = new PushbackInputStream (new BufferedInputStream (uc.getInputStream ()));
   7: 
   8:         ...
   9:             else if (saw_eoln) {
  10:                 in.unread(c);
  11:                 break;

View Full Code Here