Java 8 ByteArrayInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ByteArrayInputStream class.

This code example shows how to use the following methods:
    public byte[] asBytes() { 
        return fileItem.get(); 
    } 
 
    public InputStream asStream() { 
        return new ByteArrayInputStream(fileItem.get()); 
    } 
 
    public String getContentType() { 
        return fileItem.getContentType(); 
    } 
 
    public String getFileName() { 
        return fileItem.getName(); 
    } 
 
    public String getFieldName() { 
        return fileItem.getFieldName(); 
    } 
 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(bos);
        ByteBufferUtil.writeWithLength(bb, out);
        ByteBufferUtil.writeWithShortLength(bb, out);
 
        DataInputStream in = new DataInputStream(new ByteArrayInputStream(bos.toByteArray()));
        assert bb.equals(ByteBufferUtil.readWithLength(in));
        assert bb.equals(ByteBufferUtil.readWithShortLength(in));
    } 
 
    @Test 
    public void testInputStream() throws IOException 
    { 
        ByteBuffer bb = ByteBuffer.allocate(13);
        bb.putInt(255);
        bb.put((byte) -3);
        bb.putLong(42L);
        bb.clear();
 
        DataInputStream in = new DataInputStream(ByteBufferUtil.inputStream(bb));
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, mark
  } 
 
  @Test 
  public void testSkipFully() throws IOException { 
    byte inArray[] = new byte[] {0, 1, 2, 3, 4};
    ByteArrayInputStream in = new ByteArrayInputStream(inArray);
    try { 
      in.mark(inArray.length);
      IOUtils.skipFully(in, 2);
      IOUtils.skipFully(in, 2);
      try { 
        IOUtils.skipFully(in, 2);
        fail("expected to get a PrematureEOFException"); 
      } catch (EOFException e) {
        assertEquals(e.getMessage(), "Premature EOF from inputStream " +
            "after skipping 1 byte(s)."); 
      } 
      in.reset();
      try { 
        IOUtils.skipFully(in, 20);

10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    TypedBytesWritable tbw = new TypedBytesWritable();
    tbw.setValue(12345);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutput dout = new DataOutputStream(baos);
    tbw.write(dout);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataInput din = new DataInputStream(bais);
    TypedBytesWritable readTbw = new TypedBytesWritable();
    readTbw.readFields(din);
    assertEquals(tbw, readTbw);
  } 
 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close
    public Object decodeObject(final byte[] in) throws IOException {
        Object obj = null;
        ByteArrayInputStream bais = null;
        HessianInput input = null;
        try { 
            bais = new ByteArrayInputStream(in);
            input = new HessianInput(bais);
            input.startReply();
            obj = input.readObject();
            input.completeReply();
        } 
        catch (final IOException ex) {
            throw ex;
        } 
        catch (final Throwable e) {
            this.logger.error("Failed to decode object.", e);
        } 
        finally { 
            if (input != null) {
                try { 

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 ByteArrayInputStream Questions & Answers:

See Code Examples for Java 8 ByteArrayInputStream Methods: