Package java.io

Examples of java.io.ByteArrayInputStream.reset()


        // the hash value of an input stream or byte array.

        ByteArrayInputStream dataIS = new ByteArrayInputStream(
            "Here is my data".getBytes(Constants.DEFAULT_ENCODING));
        byte[] md5Hash = ServiceUtils.computeMD5Hash(dataIS);
        dataIS.reset();

        stringObject = new S3Object("MyData");
        stringObject.setDataInputStream(dataIS);
        stringObject.setMd5Hash(md5Hash);
View Full Code Here


        // the hash value of an input stream or byte array.

        ByteArrayInputStream dataIS = new ByteArrayInputStream(
            "Here is my data".getBytes(Constants.DEFAULT_ENCODING));
        byte[] md5Hash = ServiceUtils.computeMD5Hash(dataIS);
        dataIS.reset();

        GSObject hashObject = new GSObject("MyData");
        hashObject.setDataInputStream(dataIS);
        hashObject.setMd5Hash(md5Hash);
View Full Code Here

      // Test reading byte arrays
      int nRead;
      byte[] nData = new byte[4];

      istream.reset();
      testStream = UTF8BOMIgnoreInputStream.wrap(istream, "utf8");
      nRead = testStream.read(nData, 0, 4);
      assertEquals(4, nRead);
      assertTrue(Arrays.equals(new byte[] {0x31, 0x32, 0x33, 0x41}, nData));
      nRead = testStream.read(nData, 0, 4);
View Full Code Here

      // Test reading byte arrays
      int nRead;
      byte[] nData = new byte[4];

      istream.reset();
      testStream = UTF8BOMIgnoreInputStream.wrap(istream, "utf8");
      nRead = testStream.read(nData, 0, 4);
      assertEquals(4, nRead);
      assertTrue(Arrays.equals(new byte[] {0x31, 0x32, 0x33, 0x41}, nData));
      nRead = testStream.read(nData, 0, 4);
View Full Code Here

      // Test reading byte arrays
      int nRead;
      byte[] nData = new byte[4];

      istream.reset();
      testStream = UTF8BOMIgnoreInputStream.wrap(istream, "utf8");
      nRead = testStream.read(nData, 0, 4);
      assertEquals(-1, nRead);
   }
View Full Code Here

      // Test reading byte arrays
      int nRead;
      byte[] nData = new byte[4];

      istream.reset();
      testStream = UTF8BOMIgnoreInputStream.wrap(istream, "utf8");
      nRead = testStream.read(nData, 0, 4);
      assertEquals(-1, nRead);
   }
View Full Code Here

      // Test reading byte arrays
      int nRead;
      byte[] nData = new byte[4];

      istream.reset();
      testStream = UTF8BOMIgnoreInputStream.wrap(istream, "utf8");
      nRead = testStream.read(nData, 0, 4);
      assertEquals(1, nRead);
      assertTrue(Arrays.equals(new byte[] {(byte)0xef, 0, 0, 0}, nData));
      assertEquals(-1, testStream.read(nData, 0, 4));
View Full Code Here

         istream = new ByteArrayInputStream(m_data3);
         writer = new StringWriter();
         assertEquals(6, Base64Util.encode(istream, writer, -1, false));
         assertEquals(m_sEnc3, writer.toString());
        
         istream.reset();
         writer = new StringWriter();
         assertEquals(5, Base64Util.encode(istream, writer, 5, false));
         assertEquals(m_sEnc2, writer.toString());

         istream.reset();
View Full Code Here

         istream.reset();
         writer = new StringWriter();
         assertEquals(5, Base64Util.encode(istream, writer, 5, false));
         assertEquals(m_sEnc2, writer.toString());

         istream.reset();
         writer = new StringWriter();
         assertEquals(4, Base64Util.encode(istream, writer, 4, false));
         assertEquals(m_sEnc1, writer.toString());
      }
      catch (IOException e)
View Full Code Here

/*  751 */     byte[] buffer = null;
/*      */
/*  753 */     synchronized (this.stream)
/*      */     {
/*  755 */       int initAvail = bais.available();
/*  756 */       bais.reset();
/*  757 */       int totalAvail = bais.available();
/*  758 */       buffer = new byte[totalAvail];
/*  759 */       bais.read(buffer, 0, buffer.length);
/*  760 */       bais.reset();
/*  761 */       bais.skip(totalAvail - initAvail);
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.