Code example for FileImageOutputStream

Methods: closewrite

0
		ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
		String newFileName = servletContext.getRealPath("") + File.separator + "photocam" + File.separator + photo + ".png";
		 
		FileImageOutputStream imageOutput;
		try { 
			imageOutput = new FileImageOutputStream(new File(newFileName));
			imageOutput.write(data, 0, data.length);
			imageOutput.close();
		} 
        catch(Exception e) {
			throw new FacesException("Error in writing captured image."); 
		} 
    } 
}