/** * Copy constructor that creates a clone from a source file and set the given file * as a <b>replica</b>. * * @param file the source file to create a copy and that will be set as a replica * @throws ParameterException This happens when the source file is <tt>null</tt> */ public File(File file) throws ParameterException { if (file == null) { throw new ParameterException("File(): Error - file is null."); } // copy the attributes into the file FileAttribute fileAttr = file.getFileAttribute(); attribute.copyValue(fileAttr); fileAttr.setMasterCopy(false); // set this file to replica }
/** * Makes a copy of this file. * * @return a clone of the current file (as a replica) or <tt>null</tt> if an error occurs */ private File makeCopy() { File file = null; try { file = new File(name, attribute.getFileSize()); FileAttribute fileAttr = file.getFileAttribute(); attribute.copyValue(fileAttr); fileAttr.setMasterCopy(false); // set this file to replica } catch (Exception e) { file = null; } return file; }