Package java.io

Examples of java.io.InputStream.reset()


                            // First three bytes are not BOM, so reset.
                            stream.reset();
                        }
                    }
                    else {
                        stream.reset();
                    }
                    reader = createReader(stream, encoding, isBigEndian);
                }
                // If encoding is UTF-16, we still need to read the first four bytes
                // in order to discover the byte order.
View Full Code Here


                    for (; count < 4; ++count) {
                        b4[count] = stream.read();
                        if (b4[count] == -1)
                            break;
                    }
                    stream.reset();
                   
                    String utf16Encoding = "UTF-16";
                    if (count >= 2) {
                        final int b0 = b4[0];
                        final int b1 = b4[1];
View Full Code Here

                    for (; count < 4; ++count) {
                        b4[count] = stream.read();
                        if (b4[count] == -1)
                            break;
                    }
                    stream.reset();

                    // Ignore unusual octet order for now.
                    if (count == 4) {
                        // UCS-4, big endian (1234)
                        if (b4[0] == 0x00 && b4[1] == 0x00 && b4[2] == 0x00 && b4[3] == 0x3C) {
View Full Code Here

                    for (; count < 4; ++count) {
                        b4[count] = stream.read();
                        if (b4[count] == -1)
                            break;
                    }
                    stream.reset();

                    if (count == 4) {
                        // UCS-2, big endian
                        if (b4[0] == 0x00 && b4[1] == 0x3C && b4[2] == 0x00 && b4[3] == 0x3F) {
                            isBigEndian = Boolean.TRUE;
View Full Code Here

                // use a buffered input stream to find out whether there actually
                // is a request body
                InputStream bin = new BufferedInputStream(in);
                bin.mark(1);
                boolean isEmpty = -1 == bin.read();
                bin.reset();
                if (!isEmpty) {
                    requestDocument = DomUtil.parseDocument(bin);
                }
            }
        } catch (IOException e) {
View Full Code Here

                        return b;
                    }
                }
            }
            try {
                is.reset();
            } catch (IOException e) {
                is.close();
                is = new BufferedInputStream(new URL(bundleLocation).openStream());
            }
            LOGGER.info("Installing bundle " + bundleLocation);
View Full Code Here

        assertEquals(dst.length, is.read(dst));
        assertArrayEquals(src, dst);
        assertEquals(-1, is.read());
        is.close();

        is.reset();
        byte[] dstTooBig = new byte[src.length + 1];
        assertEquals(src.length, is.read(dstTooBig));

        assertEquals(-1, is.read(dstTooBig));
    }
View Full Code Here

                //  3) Try using the Resetable interface.
                // To avoid silent data truncation / data corruption, we fail
                // in step three if the stream isn't resetable.
                if (markSet) {
                    // 1) Reset the stream to the previously set mark.
                    srcIn.reset();
                    InputStreamUtil.skipFully(srcIn, hdrInfo.headerLength());
                } else if (in instanceof FormatIdInputStream) {
                    // 2) Add a push back stream on top of the underlying
                    // source, and unread the surplus bytes we read. Set the
                    // push back stream to be the source of the data input obj.
View Full Code Here

    final LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
    InputStream is = new LZ4BlockInputStream(open(compressed.toByteArray()), decompressor, checksum);
    assertFalse(is.markSupported());
    try {
      is.mark(1);
      is.reset();
      assertFalse(true);
    } catch (IOException e) {
      // OK
    }
    byte[] restored = new byte[data.length + 1000];
View Full Code Here

                    break;
                }
            }
            byte[] buf = new byte[ONE_KB * 3];
            int length = in.read(buf);
            in.reset();

            if (length <= 0) {
                break;
            }
            nextPos += length;
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.