Code example for FileOutputStream

Methods: close, getChannel

0
File f = new File(fullFileName);
		f.getParentFile().mkdirs();
 
		// Open the file and then get a channel from the stream 
		FileOutputStream fos = new FileOutputStream(fullFileName);
		FileChannel fc = fos.getChannel();
		ByteBuffer bb = ByteBuffer.wrap(fileContent);
		fc.write(bb);
 
		// Get the file's size and then map it into memory 
		// int fileSize = fileContent.length; 
 
		// MappedByteBuffer mbb = fc.map( FileChannel.MapMode.READ_WRITE, 0, 
		// fileSize); 
		// We write the contents of the file with one shot 
		// mbb.put(fileContent); 
 
		fos.close();
	} 
 
	/** 
	 * Get's the system's temporary directory 
	 *