src/org/ohmage/domain/Image.java
private final void writeFile(
		final ImageData imageData,
		final File destination)
		throws DomainException {
	
		LOGGER.debug("HT: Writing imageData to location: " + destination.toString());
		if(imageData == null) {
			throw new DomainException("The contents parameter is null.");
		}
		
		// Get the image data.
		InputStream contents = imageData.getInputStream();
		
		// Connect to the file that should write it.
		FileOutputStream fos;
		try {
			fos = new FileOutputStream(destination);
		}
		catch(SecurityException e) {
			throw
				new DomainException(
					"The file is not allowed to be created.",
					e);
		}
		catch(FileNotFoundException e) {
			throw new DomainException("The file cannot be created.", e);
		}
		
		// Write the image data.
		try {
			int bytesRead;
			byte[] buffer = new byte[4096];
			while((bytesRead = contents.read(buffer)) != -1) {
				fos.write(buffer, 0, bytesRead);
			}
		}
		catch(IOException e) {
			throw
				new DomainException(
					"Error reading or writing the data.",
					e);
		}
		finally {
			try {
				fos.close();
			}
			catch(IOException e) {
				throw new DomainException("Could not close the file.", e);
			}
		}
	}
/**
	 * Writes the image data to the given file. 
	 * 
	 * @param imageData The image data to be written.
	 * 
	 * @param destination The file to write the image to.
	 * 
	 * @throws DomainException There was an error reading the image data
	 * 						   or writing the file. 
	 */
Writes the image data to the given file.

@param imageData The image data to be written.

@param destination The file to write the image to.

@throws DomainException There was an error reading the image data
or writing the file.
Writes the image data to the given file . @param imageData The image data to be written . @param destination The file to write the image to . @throws DomainException There was an error reading the image data or writing the file .
private final void writeFile(
		final ImageData imageData,
		final File destination)
		throws DomainException {
		LOGGER.debug("HT: Writing imageData to location: " + destination.toString());
		if(imageData == null) {
			throw new DomainException("The contents parameter is null.");
		}
		InputStream contents = imageData.getInputStream();
		FileOutputStream fos;
		try {
			fos = new FileOutputStream(destination);
		}
		catch(SecurityException e) {
			throw
				new DomainException(
					"The file is not allowed to be created.",
					e);
		}
		catch(FileNotFoundException e) {
			throw new DomainException("The file cannot be created.", e);
		}
		try {
			int bytesRead;
			byte[] buffer = new byte[4096];
			while((bytesRead = contents.read(buffer)) != -1) {
				fos.write(buffer, 0, bytesRead);
			}
		}
		catch(IOException e) {
			throw
				new DomainException(
					"Error reading or writing the data.",
					e);
		}
		finally {
			try {
				fos.close();
			}
			catch(IOException e) {
				throw new DomainException("Could not close the file.", e);
			}
		}
	}
private final void writeFile ( final ImageData imageData , final File destination ) throws DomainException { LOGGER . debug ( "HT: Writing imageData to location: " + destination . toString ( ) ) ; if ( imageData == null ) { throw new DomainException ( "The contents parameter is null." ) ; } InputStream contents = imageData . getInputStream ( ) ; FileOutputStream fos ; try { fos = new FileOutputStream ( destination ) ; } catch ( SecurityException e ) { throw new DomainException ( "The file is not allowed to be created." , e ) ; } catch ( FileNotFoundException e ) { throw new DomainException ( "The file cannot be created." , e ) ; } try { int bytesRead ; byte [ ] buffer = new byte [ 4096 ] ; while ( ( bytesRead = contents . read ( buffer ) ) != - 1 ) { fos . write ( buffer , 0 , bytesRead ) ; } } catch ( IOException e ) { throw new DomainException ( "Error reading or writing the data." , e ) ; } finally { try { fos . close ( ) ; } catch ( IOException e ) { throw new DomainException ( "Could not close the file." , e ) ; } } }
Writes the image data to the given file.
Writes the image data to the given file .
// Get the image data. // Connect to the file that should write it. // Write the image data.