Java 8 FileOutputStream - 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 FileOutputStream 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
This code example shows how to use the following methods:
  public ProfileOutput(PrintStream out) {
    this.stream = out;
  } 
 
  public ProfileOutput(File out) throws FileNotFoundException {
    this.stream = new PrintStream(new FileOutputStream(out));
  } 
 
  public void printProfile(ProfilePrinter printer) {
    if (headerPrinted) {
      printer.printProfile(stream, false);
    } else { 
      printer.printHeader(stream);
      printer.printProfile(stream, true);
      headerPrinted = true;
      footerAndCleanupOnShutdown(printer);
    } 
  } 
 
  private void footerAndCleanupOnShutdown(final ProfilePrinter printer) {
9
CodeRank
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
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:
	public static void copyFile(final File pSourceFile, final File pDestinationFile) throws IOException {
		InputStream in = null;
		OutputStream out = null;
		try { 
			in = new FileInputStream(pSourceFile);
			out = new FileOutputStream(pDestinationFile);
			StreamUtils.copy(in, out);
		} finally { 
			StreamUtils.close(in);
			StreamUtils.close(out);
		} 
	} 
 
	/** 
	 * Deletes all files and sub-directories under <code>dir</code>. Returns 
	 * true if all deletions were successful. If a deletion fails, the method 
	 * stops attempting to delete and returns false. 
	 *  
	 * @param pFileOrDirectory 
	 * @return 
8
CodeRank
This code example shows how to use the following methods:close
		if (pictureFile == null) {
			Log.d(TAG, "Error creating media file, check storage permissions: ");
			return; 
		} 
		try { 
			FileOutputStream fos = new FileOutputStream(pictureFile);
			image.compress(Bitmap.CompressFormat.PNG, 90, fos);
			fos.close();
		} catch (FileNotFoundException e) {
			Log.d(TAG, "File not found: " + e.getMessage());
		} catch (IOException e) {
			Log.d(TAG, "Error accessing file: " + e.getMessage());
		} 
	} 
 
	/** 
	 * Get the screen height. 
	 *  
	 * @param context 
	 * @return the screen height 
8
CodeRank
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
This code example shows how to use the following methods:
 
 
    @Override 
    protected void persistSerializedSessions(String deploymentName, Map<String, SessionEntry> serializedData) throws IOException {
        File file = new File(baseDir, deploymentName);
        FileOutputStream out = new FileOutputStream(file, false);
        try { 
            Marshaller marshaller = createMarshaller();
            try { 
                marshaller.start(new OutputStreamByteOutput(out));
                marshaller.writeObject(serializedData);
                marshaller.finish();
            } finally { 
                marshaller.close();
            } 
        } finally { 
            IoUtils.safeClose(out);
        } 
    } 
 

8
CodeRank
This code example shows how to use the following methods:
      return null; 
    } 
    File historyFile = new File(historyRoot, "history-" + System.currentTimeMillis() + ".csv");
    OutputStreamWriter out = null;
    try { 
      out = new OutputStreamWriter(new FileOutputStream(historyFile), Charset.forName("UTF-8"));
      out.write(history);
      return Uri.parse("file://" + historyFile.getAbsolutePath());
    } catch (IOException ioe) {
      Log.w(TAG, "Couldn't access file " + historyFile + " due to " + ioe);
      return null; 
    } finally { 
      if (out != null) {
        try { 
          out.close();
        } catch (IOException ioe) {
          // do nothing 
        } 
      } 
    } 
9
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

Related Java 8 FileOutputStream Questions & Answers:

Other Java 8 FileOutputStream Examples

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

Read More

107:		            // Output stream
108:		            OutputStream output = new FileOutputStream("/sdcard/downloadedfile.jpg");
109:	
110:		            byte data[] = new byte[1024];
111:

Read More

71:	            conn.setInstanceFollowRedirects(true);
72:	            InputStream is=conn.getInputStream();
73:	            OutputStream os = new FileOutputStream(f);
74:	            Utils.CopyStream(is, os);
75:	            os.close();

Read More

See Code Examples for Java 8 FileOutputStream Methods: