Interaction with the file system isn't recommended within EJB. Below is the excerpt from the EJB Restrictions which explains it.
Why can't EJBs read and write files and directories in the filesystem? And why can't they access file descriptors?
Enterprise beans aren't allowed to access files primarily because files are not transactional resources. Allowing EJBs to access files or directories in the filesystem, or to use file descriptors, would compromise component distributability, and would be a security hazard.
As file isn't a transactional resource, rollback will have no effect on it.