Package java.io

Examples of java.io.BufferedInputStream.reset()


        int bytesRead = bin.read(peek);
        if (bytesRead != peek.length) {
            throw new IOException("Read only " + bytesRead
                    + "bytes, expecting " + peek.length);
        }
        bin.reset();

        if ((new String(peek)).startsWith("<?xm")) {
            // file is an XML file.
            PlotBoxMLParser parser;
View Full Code Here


        int bytesRead = bin.read(peek);
        if (bytesRead != peek.length) {
            throw new IOException("Read only " + bytesRead
                    + "bytes, expecting " + peek.length);
        }
        bin.reset();

        if ((new String(peek)).startsWith("<?xm")) {
            // file is an XML file.
            PlotMLParser parser = _newParser();
View Full Code Here

        final PrintWriter out = new PrintWriter(new OutputStreamWriter(outStream , "UTF-8"));
        final BufferedInputStream in = new BufferedInputStream(inStream);
       
        in.mark(10000); // assume the header is never larger than 10000 bytes.
        copyHeader(in, out);
        in.reset(); // reposition the stream at the beginning
           
        try {
          UpdaterHandler updaterHandler = new UpdaterHandler(settings,out,resolvedRevisions,status,revision,pubdate,ns,replaceInclude);
      XMLHelper.parse(in, null, updaterHandler, updaterHandler);
        } catch (ParserConfigurationException e) {
View Full Code Here

                   
                    // Check for zip header magic 0x50 0x4b 0x03 0x04
                    is.mark(0);
                    boolean zipHeaderMatch = is.read() == 0x50 && is.read() == 0x4b && is.read() == 0x03 &&
                        is.read() == 0x04;
                    is.reset();
                   
                    if (zipHeaderMatch) {
                        // The URL provides a Jar-formatted InputStream, consume it with ZipStreamMetaDataIterator
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-at-url", url));
View Full Code Here

          _stream = new NPOIFSStream(_filesystem);
          _block_size = _filesystem.getBlockStoreBlockSize();
       }

       // start from the beginning
       bis.reset();
      
       // Store it
       OutputStream os = _stream.getOutputStream();
       byte buf[] = new byte[1024];
       int length = 0;
View Full Code Here

        InputStream in = new BufferedInputStream(
                new ByteArrayInputStream(bytes), 12);
        in.skip(6);
        in.mark(14);
        in.read(new byte[14], 0, 14);
        in.reset();
        assertTrue("Wrong bytes", in.read() == 6 && in.read() == 7);

        in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
        in.skip(6);
        in.mark(8);
View Full Code Here

        in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
        in.skip(6);
        in.mark(8);
        in.skip(7);
        in.reset();
        assertTrue("Wrong bytes 2", in.read() == 6 && in.read() == 7);

        BufferedInputStream buf = new BufferedInputStream(
                new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4 }), 2);
        buf.mark(3);
View Full Code Here

                new ByteArrayInputStream("1234567890".getBytes()));
        bIn.mark(10);
        for (int i = 0; i < 11; i++) {
            bIn.read();
        }
        bIn.reset();
    }

    /**
     * @tests java.io.BufferedInputStream#reset()
     */
 
View Full Code Here

    public void test_reset_Exception() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(null);

        // throws IOException with message "Mark has been invalidated"
        try {
            bis.reset();
            fail("should throw IOException");
        } catch (IOException e) {
            // expected
        }
View Full Code Here

            // expected
        }

        // does not throw IOException
        bis.mark(1);
        bis.reset();

        bis.close();

        // throws IOException with message "stream is closed"
        try {
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.