Package java.io

Examples of java.io.ByteArrayInputStream.reset()


    final ByteArrayInputStream stream = new ByteArrayInputStream(data);
    if (isGIF(stream))
    {
      return "image/gif";
    }
    stream.reset();
    if (isJPEG(stream))
    {
      return "image/jpeg";
    }
    stream.reset();
View Full Code Here


    stream.reset();
    if (isJPEG(stream))
    {
      return "image/jpeg";
    }
    stream.reset();
    if (isPNG(stream))
    {
      return "image/png";
    }
    return null;
View Full Code Here

          }
          catch (Exception e) {
            assertThat(e.getMessage(), containsString("failed to create"));
          }
          for (int i = 0; i < fileNames.length; i++) {
            stream.reset();
            session.write(stream, "si.sftp.sample/" + fileNames[i]);
          }
          return null;
        }
      });
View Full Code Here

        fail("expected to get a PrematureEOFException");
      } catch (EOFException e) {
        assertEquals("Premature EOF from inputStream " +
                "after skipping 1 byte(s).",e.getMessage());
      }
      in.reset();
      try {
        IOUtils.skipFully(in, 20);
        fail("expected to get a PrematureEOFException");
      } catch (EOFException e) {
        assertEquals("Premature EOF from inputStream " +
View Full Code Here

        fail("expected to get a PrematureEOFException");
      } catch (EOFException e) {
        assertEquals("Premature EOF from inputStream " +
                "after skipping 5 byte(s).",e.getMessage());
      }
      in.reset();
      IOUtils.skipFully(in, 5);
      try {
        IOUtils.skipFully(in, 10);
        fail("expected to get a PrematureEOFException");
      } catch (EOFException e) {
View Full Code Here

        throws SQLException {
    InputStream blobInput = new ByteArrayInputStream(blobData, 0, blobData.length);
        PreparedStatement pStmt =
            con.prepareStatement("update BLOBCLOB set BLOBDATA = ? where ID = ?");
        try {
            blobInput.reset();
        } catch (IOException ioe) {
            fail("Failed to reset blob input stream: " + ioe.getMessage());
        }
        pStmt.setBlob(1, blobInput, blobData.length);
        pStmt.setInt(2, ID_SAMPLEVALUES);
View Full Code Here

    for(int idx = 0; idx < numRecords; idx++) {
      records[idx].write(dout);
    }
    times.write = System.nanoTime() - times.write;
   
    bin.reset();
    DataInputStream din = new DataInputStream(bin);
   
    times.readFields = System.nanoTime();
    for(int idx = 0; idx < numRecords; idx++) {
      records[idx].readFields(din);
View Full Code Here

                try {
                    doUpload(getBlobStore(), getBucketName(), getBlobName(), is, len, isServerSideEncryption());
                    break;
                } catch (AmazonS3Exception e) {
                    if (shouldRetry(e)) {
                        is.reset();
                        retry++;
                    } else {
                        throw new IOException("Unable to upload object " + getBlobName(), e);
                    }
                }
View Full Code Here

                    multiparts.add(partETag);
                    multipartChunks++;
                    return;
                } catch (AmazonS3Exception e) {
                    if (shouldRetry(e) && retry < getNumberOfRetries()) {
                        is.reset();
                        retry++;
                    } else {
                        abortMultipart();
                        throw e;
                    }
View Full Code Here

        uctx.setDocument(baos, null, "UTF-8", false);
        T obj = type.cast(uctx.unmarshalElement());

        // Find out version
        XMLInputFactory factory = XMLInputFactory.newInstance();
        baos.reset();
        XMLStreamReader reader = factory.createXMLStreamReader(baos);
        Version version = Version.UNKNOWN;
        while (reader.hasNext()) {
            int next = reader.next();
            if (next == XMLStreamReader.START_ELEMENT) {
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.