OutputStream flush - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for OutputStream flush method.

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
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
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
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
This code example shows how to use the following methods:close, flush, write
     * @param file The file to write 
     */ 
    public static void write(byte[] data, File file) {
        OutputStream os = null;
        try { 
            os = new FileOutputStream(file);
            os.write(data);
            os.flush();
        } catch(IOException e) {
            throw new UnexpectedException(e);
        } finally { 
            try { 
                if(os != null) os.close();
            } catch(Exception e) {
                // 
            } 
        } 
    } 
 
    /** 
9
CodeRank
This code example shows how to use the following methods:flush
        out.write(b, offset, length);
    } 
 
    @Override 
    public void flush() throws IOException { 
        out.flush();
    } 
 
    @Override 
    public void close() throws IOException { 
        out.close();
    } 
 
    @Override 
    public void reset() throws IOException { 
        throw new UnsupportedOperationException();
    } 
} 
8
CodeRank
This code example shows how to use the following methods:close, flush
			//fos = activity.openFileOutput(APP_CONFIG, Context.MODE_PRIVATE); 
			 
			//把config建在(自定义)app_config的目录下 
			File dirConf = mContext.getDir(APP_CONFIG, Context.MODE_PRIVATE);
			File conf = new File(dirConf, APP_CONFIG);
			fos = new FileOutputStream(conf);
			 
			p.store(fos, null);
			fos.flush();
		}catch(Exception e){	
			e.printStackTrace();
		}finally{ 
			try { 
				fos.close();
			} catch (Exception e) {}
		} 
	} 
 
	public void set(Properties ps)
	{ 
8
CodeRank
This code example shows how to use the following methods:close, flush, write
            return udid;
        } 
         
        FileOutputStream fos = null;
        try { 
            fos = new FileOutputStream(file);
            fos.write(udid.getBytes());
            fos.flush();
            Logger.i(TAG, "Saved udid into file");
        } catch (IOException e) {
            Logger.e(TAG, "write file error", e);
        } finally { 
            try { 
                if (null != fos) {
                    fos.close();
                } 
            } catch (IOException e) {
            } 
        } 
         
8
CodeRank
This code example shows how to use the following methods:close, flush
        return refs;
    } 
 
    public static void writeRef(final File file, final String ref) throws IOException {
        mkdir(file.getParentFile());
        final OutputStream os = new FileOutputStream(file);
        try { 
            writeLine(os, ref);
            os.flush();
            os.close();
        } finally { 
            safeClose(os);
        } 
    } 
 
    public static void writeRefs(final File file, final List<String> refs) throws IOException {
        mkdir(file.getParentFile());
        final OutputStream os = new FileOutputStream(file);
        try { 
            writeRefs(os, refs);
8
CodeRank
This code example shows how to use the following methods:close, flush, write
 
		deleteImage(filename, path);
		if (data != null) {
			FileOutputStream fOut;
			try { 
				fOut = new FileOutputStream(new File(path, filename), false);
				fOut.write(data);
				fOut.flush();
				fOut.close();
			} catch (final FileNotFoundException e) {
 
				e.printStackTrace();
			} catch (final IOException e) {
 
				e.printStackTrace();
			} 
		} 
 
	} 
	 
7
CodeRank

Related OutputStream flush Questions & Answers:

Other OutputStream flush Examples

124:		            // flushing output
125:		            output.flush();
126:	
127:		            // closing streams
128:		            output.close();

Read More

47:		            // flushing output
48:		            output.flush();
49:	
50:		            // closing streams
51:		            output.close();

Read More

flush Method Overview
Flushes this output stream and forces any buffered output bytes to be written out.
See Code Examples for other Java 8 OutputStream Methods: