Package java.io

Examples of java.io.BufferedInputStream.mark()


            throw new NullPointerException("No password supplied for PKCS#12 KeyStore.");
        }

        BufferedInputStream             bufIn = new BufferedInputStream(stream);

        bufIn.mark(10);

        int head = bufIn.read();

        if (head != 0x30)
        {
View Full Code Here


            }
            // workaround for pre-1.3 VMs that don't recognize UTF-16
            if (version.startsWith("1.2"|| version.startsWith("1.1")) {
                if (encoding.equalsIgnoreCase("UTF-16")) {
                    // is it  big-endian or little-endian?
                    in.mark(2);
                    int first = in.read();
                    if (first == 0xFF) encoding = "UnicodeLittle";
                    else encoding="UnicodeBig";
                    in.reset()
                }
View Full Code Here

        {
            enc = "ISO-8859-1";
        }

        BufferedInputStream is = new BufferedInputStream(conn.getInputStream());
        is.mark(20480);
        BufferedReader asciiReader = new BufferedReader(new InputStreamReader(is, "ASCII"));
        String decl = asciiReader.readLine();
        String key = "encoding=\"";
        if (decl != null)
        {
View Full Code Here

        }
    InputStream in = new BufferedInputStream(
        new ByteArrayInputStream(bytes), 12);
    try {
      in.skip(6);
      in.mark(14);
      in.read(new byte[14], 0, 14);
      in.reset();
      assertTrue("Wrong bytes", in.read() == 6 && in.read() == 7);
    } catch (IOException e) {
      fail("Exception during mark test 2");
View Full Code Here

    }

    in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
    try {
      in.skip(6);
      in.mark(8);
      in.skip(7);
      in.reset();
      assertTrue("Wrong bytes 2", in.read() == 6 && in.read() == 7);
    } catch (IOException e) {
      fail("Exception during mark test 3");
View Full Code Here

      assertTrue("Reset failed", new String(buf1, 0, buf1.length)
          .equals(new String(buf2, 0, buf2.length)));

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

    } catch (IOException e) {
      // expected
    }
   
    //does not throw IOException
    bis.mark(1);
    bis.reset();
   
    bis.close();

    //throws IOException with message "stream is closed"
View Full Code Here

   * @tests java.io.BufferedInputStream#mark(int)
   */
  public void test_markI() throws IOException {
    BufferedInputStream buf = new BufferedInputStream(
        new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4 }), 2);
    buf.mark(3);
    byte[] bytes = new byte[3];
    int result = buf.read(bytes);
    assertEquals(3, result);
    assertEquals("Assert 0:", 0, bytes[0]);
    assertEquals("Assert 1:", 1, bytes[1]);
View Full Code Here

    assertEquals("Assert 2:", 2, bytes[2]);
    assertEquals("Assert 3:", 3, buf.read());

    buf = new BufferedInputStream(
        new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4 }), 2);
    buf.mark(3);
    bytes = new byte[4];
    result = buf.read(bytes);
    assertEquals(4, result);
    assertEquals("Assert 4:", 0, bytes[0]);
    assertEquals("Assert 5:", 1, bytes[1]);
View Full Code Here

    assertEquals("Assert 8:", 4, buf.read());
    assertEquals("Assert 9:", -1, buf.read());

    buf = new BufferedInputStream(
        new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4 }), 2);
    buf.mark(Integer.MAX_VALUE);
    buf.read();
    buf.close();
  }
 
  /*
 
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.