Java 8 OutputStream - 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 OutputStream class.

This code example shows how to use the following methods:close, flush, write
			if (osCommon != null) {
				osCommon.write(data);
				osCommon.flush();
				osCommon.close();
			} 
			OutputStream osOwn = new FileOutputStream(filePath);
			osOwn.write(data);
			osOwn.flush();
			osOwn.close();
 
			com.rhomobile.rhodes.camera.Camera.doCallback(callbackUrl, filePath, mImgWidth, mImgHeight, mImgFormat);
			mOwner.finish();
 
		} catch (Exception e) {
			Logger.E(TAG, e);
		} 
	} 
	 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close
 
    public static byte[] copy(final InputStream is, final File target) throws IOException {
        if(! target.getParentFile().exists()) {
            target.getParentFile().mkdirs(); // Hmm
        } 
        final OutputStream os = new FileOutputStream(target);
        try { 
            byte[] nh = HashUtils.copyAndGetHash(is, os);
            os.close();
            return nh;
        } finally { 
            safeClose(os);
        } 
    } 
 
    public static byte[] copy(File source, File target) throws IOException {
        final FileInputStream is = new FileInputStream(source);
        try { 
            byte[] backupHash = copy(is, target);
            is.close();
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:writeInt, writeShort, write
	@Override 
	public void writeData(DataOutputStream data) throws IOException {
 
		super.writeData(data);
 
		data.writeInt(slot);
		if (stack != null) {
			data.writeInt(stack.itemID);
			data.writeInt(stack.stackSize);
			data.writeInt(stack.getItemDamage());
			 
			if(stack.hasTagCompound()) {
				byte[] compressed = CompressedStreamTools.compress(stack.getTagCompound());
				data.writeShort(compressed.length);
				data.write(compressed);
			} else { 
				data.writeShort(0);
			} 
 
		} else { 

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, flush, write
    public void testgetLocations() throws IOException{ 
        JobConf job= new JobConf();
       
      File tmpFile = File.createTempFile("test","txt");
      tmpFile.createNewFile();
      OutputStream out=new FileOutputStream(tmpFile);
      out.write("tempfile".getBytes());
      out.flush();
      out.close();
      Path[] path= {new Path(tmpFile.getAbsolutePath())};
      long[] lengths = {100};
       
      MultiFileSplit  split = new MultiFileSplit(job,path,lengths);
     String [] locations= split.getLocations();
     assertTrue(locations.length==1);
     assertEquals(locations[0], "localhost");
    } 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:flush, write
  private static long OFFSET_IN_BLOCK = 12345L;
  private static int SEQNO = 54321;
 
  private byte[] prepareFakePacket(byte[] data, byte[] sums) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
     
    int packetLen = data.length + sums.length + 4;
    PacketHeader header = new PacketHeader(
        packetLen, OFFSET_IN_BLOCK, SEQNO, false, data.length, false);
    header.write(dos);
     
    dos.write(sums);
    dos.write(data);
    dos.flush();
    return baos.toByteArray();
  } 
   
  private static byte[] remainingAsArray(ByteBuffer buf) {
    byte[] b = new byte[buf.remaining()];
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, write
public abstract class StreamCompressionStrategy implements CompressionStrategy { 
 
    public byte[] deflate(byte[] data) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        OutputStream gos = wrapOutputStream(bos);
        gos.write(data);
        gos.close();
        return bos.toByteArray();
    } 
 
    protected abstract OutputStream wrapOutputStream(OutputStream underlying) throws IOException;
 
    protected abstract InputStream wrapInputStream(InputStream underlying) throws IOException;
 
    public byte[] inflate(byte[] data) throws IOException {
        InputStream is = wrapInputStream(new ByteArrayInputStream(data));
        byte[] inflated = IOUtils.toByteArray(is);
        is.close();
        return inflated;
    } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, write
  public void setup() throws IOException { 
    FileUtil.fullyDelete(TEST_DIR);
    assertTrue(TEST_DIR.mkdirs());
     
    // Write a file out 
    FileOutputStream fos = new FileOutputStream(TEST_FILE);
    fos.write(TEST_DATA);
    fos.close();
  } 
   
  @Test 
  public void testComputeMd5ForFile() throws Exception { 
    MD5Hash computedDigest = MD5FileUtils.computeMd5ForFile(TEST_FILE);
    assertEquals(TEST_MD5, computedDigest);    
  } 
 
  @Test 
  public void testVerifyMD5FileGood() throws Exception { 
    MD5FileUtils.saveMD5File(TEST_FILE, TEST_MD5);
    MD5FileUtils.verifySavedMD5(TEST_FILE, TEST_MD5);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:flush, write
     * 
     * @throws IOException if an I/O error occurs. 
     */ 
    public void flush() throws IOException { 
        flushBuffer(); 
        _outputStream.flush();
    } 
 
    /** 
     * Closes and {@link #reset resets} this writer for reuse. 
     * 
     * @throws IOException if an I/O error occurs 
     */ 
    public void close() throws IOException { 
        if (_outputStream != null) {
            flushBuffer(); 
            _outputStream.close();
            reset(); 
        } 
    } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close
        out.flush();
    } 
 
    @Override 
    public void close() throws IOException { 
        out.close();
    } 
 
    @Override 
    public void reset() throws IOException { 
        throw new UnsupportedOperationException();
    } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, flush, write
    if (closed) {
      return; 
    } 
    closed = true;
    finish(); 
    out.close();
  } 
 
  /** 
   * Finishes writing data to the output stream, by writing 
   * the checksum bytes to the end. The underlying stream is not closed. 
   * @throws IOException 
   */ 
  public void finish() throws IOException { 
    if (finished) {
      return; 
    } 
    finished = true;
    sum.writeValue(barray, 0, false);
    out.write (barray, 0, sum.getChecksumSize());

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 OutputStream Questions & Answers:

Other Java 8 OutputStream Examples

4:	 
5:	public class Utils {
6:	    public static void CopyStream(InputStream is, OutputStream os)
7:	    {
8:	        final int buffer_size=1024;

Read More

4:	public class Utils {
5:	    public static void CopyStream(InputStream is, OutputStream os)
6:	    {
7:	        final int buffer_size=1024;
8:	        try

Read More

30:		            // Output stream to write file
31:		            OutputStream output = new FileOutputStream("/sdcard/downloadedfile.jpg");
32:	
33:		            byte data[] = new byte[1024];
34:

Read More

See Code Examples for Java 8 OutputStream Methods: