Package java.io

Examples of java.io.BufferedInputStream.reset()


  public void test_reset_Exception() throws IOException {
    BufferedInputStream bis = new BufferedInputStream(null);
   
    //throws IOExcepiton 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

   
    bis.close();

    //throws IOException with message "stream is closed"
    try {
      bis.reset();
      fail("should throw IOException");
    } catch (IOException e) {
      // expected
    }
  }
View Full Code Here

            throw new NullPointerException();
        }
        BufferedInputStream bis = new BufferedInputStream(in);
        bis.mark(Integer.MAX_VALUE);
        boolean isEbcdic = isEbcdic(bis);
        bis.reset();

        if(!isEbcdic){
            loadImpl(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
        }else{
            loadImpl(new InputStreamReader(bis)); //$NON-NLS-1$
View Full Code Here

        byte[] headerBytes = new byte[HEADER_LEN];
        int actualRead = bufferedIn.read(headerBytes, 0, HEADER_LEN);
        if (actualRead != -1) {
          String header = new String(headerBytes);
          if (header.compareTo(HEADER) != 0) {
            bufferedIn.reset();
          }
        }
      }

      if (bufferedIn == null) {
View Full Code Here

                os.write(lineFeed);
                os.flush();
                readAck(is, false);

                // now send the stream
                buffer.reset();
                while ((read = buffer.read(reply)) != -1) {
                    os.write(reply, 0, read);
                }
                writeAck(os);
                readAck(is, false);
View Full Code Here

        in.mark(100);
        for (int i = 0; i < 10; i++) {
            assertEquals(0, in.read());
        }
        assertEquals(-1, in.read());
        in.reset();
        for (int i = 0; i < 10; i++) {
            assertEquals(0, in.read());
        }
        assertEquals(-1, in.read());
        in.close();
View Full Code Here

        BufferedInputStream bis = new BufferedInputStream( is, 64 * 1024 );
        bis.mark( 64 * 1024 );
        JarInputStream jis = new JarInputStream( bis );
        mf.getMainAttributes().putAll( jis.getManifest().getMainAttributes() );
        mf.getEntries().putAll( jis.getManifest().getEntries() );
        bis.reset();
        return bis;
    }

    /**
     * Parse a given OSGi header into a list of paths
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) {
                    DocumentBuilder docBuilder = DomUtil.BUILDER_FACTORY.newDocumentBuilder();
                    requestDocument = docBuilder.parse(bin);
                }
            }
View Full Code Here

        final PrintWriter out = new PrintWriter(new OutputStreamWriter(outStream, "UTF-8"));
        final BufferedInputStream in = new BufferedInputStream(inStream);

        in.mark(MAX_HEADER_LENGTH); // 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(inStreamCtx, out, options);
            InputSource inSrc = new InputSource(in);
            if (inStreamCtx != null) {
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.