Refine search
private void writeFile() throws BuildException { // Write to RAM first, as an OOME could otherwise produce a truncated file: ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { properties.store(baos, comment); } catch (IOException x) { // should not happen throw new BuildException(x, getLocation()); } try { try (OutputStream os = Files.newOutputStream(propertyfile.toPath())) { os.write(baos.toByteArray()); } catch (IOException x) { // possibly corrupt FileUtils.getFileUtils().tryHardToDelete(propertyfile); throw x; } } catch (IOException x) { // opening, writing, or closing throw new BuildException(x, getLocation()); } }
/** * Convenience method to copy a file from a source to a destination. No filtering is performed. * * @param sourceFile the file to copy from. Must not be <code>null</code>. * @param destFile the file to copy to. Must not be <code>null</code>. * * @throws IOException if the copying fails. */ public void copyFile(File sourceFile, File destFile) throws IOException { copyFile(sourceFile, destFile, null, false, false); }
/** * Copy task constructor. */ public Copy() { fileUtils = FileUtils.getFileUtils(); granularity = fileUtils.getFileTimestampGranularity(); }
/** * Resolve a filename with Project's help - if we know one that is. */ private static File resolveFile(Project project, String relativeName) { return FileUtils.getFileUtils().resolveFile( (project == null) ? null : project.getBaseDir(), relativeName); }
/** * convert a file to a URL; * * @param fileToConvert File * @return the file converted to a URL */ private String toURL(File fileToConvert) { //create the URL //ant equivalent of fileToConvert.toURI().toURL().toExternalForm(); return FileUtils.getFileUtils().toURI(fileToConvert.getAbsolutePath()); }
String encFileName = absolutePath.substring(0, index + 1) + UserStoreConfigurationConstants.XML_EXTENSION; OutputStream outputStream; outputStream = new FileOutputStream(encFileName); secondaryStoreDocument.serialize(outputStream); FileUtils.delete(file);
throws IOException File f = fileUtils.resolveFile( dest, entryName ); try fos = new FileOutputStream( f ); fos.write( buffer, 0, length ); fos.close(); fos = null; fileUtils.setFileLastModified( f, entryDate.getTime() );
OutputStream outstream = null; try { File file = getProject().resolveFile(new File(dir, filename).getPath()); pdir.mkdirs(); outstream = new BufferedOutputStream(new FileOutputStream(file)); ftp.retrieveFile(resolveFile(filename), outstream); skipped++; } else { throw new BuildException(s); FTPFile[] remote = ftp.listFiles(resolveFile(filename)); if (remote.length > 0) { FILE_UTILS.setFileLastModified(file, remote[0].getTimestamp() .getTime().getTime()); FileUtils.close(outstream);
a.putValue( "Class-Path", classPath ); a.remove( new Attributes.Name( "Maven-Class-Path" ) ); OutputStream os = new FileOutputStream( moduleFile ); try FileUtils.getFileUtils().copyFile( jarFile, moduleFile, null, true, false ); FileUtils.getFileUtils().copyFile( source, target, null, true, false ); if ( externals != null && externals.contains(artifact.getGroupId() + ":" + artifact.getArtifactId())) // MNBMODULE-138 getLog().info( "Generating JavaHelp Index..." ); JHIndexer jhTask = (JHIndexer) antProject.createTask( "jhindexer" ); jhTask.setBasedir( b ); jhTask.setDb( p ); throw new MojoExecutionException( e.getMessage(), e ); Jar jar = (Jar) antProject.createTask( "jar" ); jar.setDestFile( new File( helpJarLocation, moduleJarName + ".jar" ) ); set = new FileSet(); throw new MojoExecutionException( e.getMessage(), e ); MakeListOfNBM makeTask = (MakeListOfNBM) antProject.createTask( "genlist" ); throw new MojoExecutionException( e.getMessage(), e );
throw new BuildException("Replace: source file " + src.getPath() + " doesn't exist", getLocation()); File temp = fileUtils.createTempFile("rep", ".tmp", fileUtils.getParentFile(src)); temp.deleteOnExit(); try { reader = encoding == null ? new FileReader(src) : new InputStreamReader(new FileInputStream(src), encoding); writer = encoding == null ? new FileWriter(temp) : new OutputStreamWriter(new FileOutputStream(temp), encoding); String buf = fileUtils.readFully(br); if (buf == null) { buf = ""; if (replacefilters.size() > 0) { newString = processReplacefilters(newString, src.getPath()); Project tempProject = new Project(); Delete delete = new Delete(); delete.setProject(tempProject); throw new BuildException("IOException in " + src + " - " + ioe.getClass().getName() + ":" + ioe.getMessage(), ioe, getLocation()); } finally {
public void output(JSLintResult result) { File f = new File(file, testFileName(result)); Writer w = null; try { w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), "UTF-8")); if (form.header() != null) { w.write(form.header()); } w.write(form.format(result)); if (form.footer() != null) { w.write(form.footer()); } } catch (IOException e) { throw new BuildException(e); } finally { FileUtils.close(w); } }
public static void writeToFile(Properties properties, File file, String comment) throws IOException { // write to memory first to prevent other side-effects ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { properties.store(baos, comment); } finally { baos.close(); } OutputStream os = new FileOutputStream(file); try { os.write(baos.toByteArray()); } catch (IOException ex) { FileUtils.getFileUtils().tryHardToDelete(file); throw ex; } finally { os.close(); } }
dir = getProject().getBaseDir(); newProject.setBaseDir(dir); if (savedDir != null) { newProject.setInheritedProperty(MagicNames.PROJECT_BASEDIR, dir.getAbsolutePath()); File file = FILE_UTILS.resolveFile(dir, antFile); antFile = file.getAbsolutePath(); + (locals.isEmpty() ? "[default]" : locals.toString()) + " in build file " + antFile, Project.MSG_VERBOSE); newProject.setUserProperty(MagicNames.ANT_FILE, antFile); throw new BuildException( "%s task at the top level must not invoke its own build file.", getTaskName()); if (locals.isEmpty()) { String defaultTarget = newProject.getDefaultTarget(); if (defaultTarget != null) { FileUtils.close(out);
FilterChain fc = new FilterChain(); fc.add(filter); fcv = new Vector<>(1); fcv.add(fc); File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, true); try { FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, true, false, encoding, outputEncoding == null ? encoding : outputEncoding, getProject()); destIsWrong = !FILE_UTILS.contentEquals(destFile, tmpFile); log(destFile + (destIsWrong ? " is being written" : " is not written, as the contents are identical"), FILE_UTILS.rename(tmpFile, destFile); if (preserveLastModified) { log("preserved lastModified for " + destFile, Project.MSG_DEBUG); FILE_UTILS.setFileLastModified(destFile, lastModified); throw new BuildException("error running fixcrlf on file " + srcFile, e); } finally { if (tmpFile != null && tmpFile.exists()) { FILE_UTILS.tryHardToDelete(tmpFile);
super.execute(); try { for (int i = 0; i < rcs.size(); i++) { ResourceCollection rc = (ResourceCollection) rcs.elementAt(i); Iterator<Resource> resources = rc.iterator(); while (resources.hasNext()) { Resource r = (Resource) resources.next(); if (!r.isExists()) { continue; throw new BuildException("Unable to recognize the path separator for src file: " + file); File specificDestinationFile = new File(destDir, specificFilePart); if (specificFile.exists()) { fileUtils.copyFile(specificFile, specificDestinationFile); continue; File generalFile = new File(licenseDir, generalFilePart); if (generalFile.exists()) { fileUtils.copyFile(generalFile, specificDestinationFile); continue; File moreGeneralFile = new File(licenseDir, moreGeneralFilePart); if (moreGeneralFile.exists()) { fileUtils.copyFile(moreGeneralFile, specificDestinationFile); throw new BuildException(e);
List<Transaction> savedTransaction = new Vector<>(transactions); String savedSqlCommand = sqlCommand; throw new BuildException("Source file " + srcFile + " is not a file!", getLocation()); OutputStream os = null; FileProvider fp = output.as(FileProvider.class); if (fp != null) { os = FileUtils.newOutputStream(fp.getFile().toPath(), append); } else { if (append) { Appendable a = output.as(Appendable.class); if (a != null) { os = a.getAppendOutputStream(); os = output.getOutputStream(); if (append) { log("Ignoring append=true for non-appendable" FileUtils.close(out); FileUtils.close(getStatement()); } catch (SQLException ex) { FileUtils.close(getConnection());
checkTaskName(); final List<String> packagesToDoc = new Vector<>(); final Path sourceDirs = new Path(getProject()); tmpList = FILE_UTILS.createTempFile("javadoc", "", null, true, true); toExecute.createArgument() .setValue("@" + tmpList.getAbsolutePath()); tmpList.delete(); throw new BuildException("Error creating temporary file", e, getLocation()); } finally { FileUtils.close(wr); final int ret = exe.execute(); if (ret != 0 && failOnError) { throw new BuildException("Javadoc returned " + ret, getLocation()); throw new BuildException("Javadoc issued warnings.", getLocation()); FileUtils.close(out); FileUtils.close(err);
analyzedDeps.addAll(classFile.getClassRefs()); } finally { FileUtils.close(inStream); FileUtils.close(zipFile); files.removeAllElements(); files.addAll(containers); classes.removeAllElements(); classes.addAll(dependencies);
helperImpl.project.setDefault(def); } else { throw new BuildException("The default attribute is required"); helperImpl.project.setName(name); helperImpl.project.addReference(name, helperImpl.project); helperImpl.project.setBasedir(baseDir); } else { File resolvedBaseDir = FILE_UTILS.resolveFile(helperImpl.buildFileParent, baseDir); helperImpl.project.setBaseDir(resolvedBaseDir);