本文整理汇总了Java中org.apache.tools.ant.taskdefs.Delete.setFile方法的典型用法代码示例。如果您正苦于以下问题:Java Delete.setFile方法的具体用法?Java Delete.setFile怎么用?Java Delete.setFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.taskdefs.Delete
的用法示例。
在下文中一共展示了Delete.setFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTimeDiff
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* auto find the time difference between local and remote
* @param ftp handle to ftp client
* @return number of millis to add to remote time to make it comparable to local time
* @since ant 1.6
*/
private long getTimeDiff(FTPClient ftp) {
long returnValue = 0;
File tempFile = findFileName(ftp);
try {
// create a local temporary file
FILE_UTILS.createNewFile(tempFile);
long localTimeStamp = tempFile.lastModified();
BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath()));
ftp.storeFile(tempFile.getName(), instream);
instream.close();
if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
FTPFile [] ftpFiles = ftp.listFiles(tempFile.getName());
if (ftpFiles.length == 1) {
long remoteTimeStamp = ftpFiles[0].getTimestamp().getTime().getTime();
returnValue = localTimeStamp - remoteTimeStamp;
}
ftp.deleteFile(ftpFiles[0].getName());
}
// delegate the deletion of the local temp file to the delete task
// because of race conditions occurring on Windows
Delete mydelete = new Delete();
mydelete.bindToOwner(task);
mydelete.setFile(tempFile.getCanonicalFile());
mydelete.execute();
} catch (Exception e) {
throw new BuildException(e, task.getLocation());
}
return returnValue;
}
示例2: getTimeDiff
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* auto find the time difference between local and remote
* @param ftp handle to ftp client
* @return number of millis to add to remote time to make it comparable to local time
* @since ant 1.6
*/
private long getTimeDiff(FTPClient ftp) {
long returnValue = 0;
File tempFile = findFileName(ftp);
try {
// create a local temporary file
FILE_UTILS.createNewFile(tempFile);
long localTimeStamp = tempFile.lastModified();
BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath()));
ftp.storeFile(tempFile.getName(), instream);
instream.close();
boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode());
if (success) {
FTPFile [] ftpFiles = ftp.listFiles(tempFile.getName());
if (ftpFiles.length == 1) {
long remoteTimeStamp = ftpFiles[0].getTimestamp().getTime().getTime();
returnValue = localTimeStamp - remoteTimeStamp;
}
ftp.deleteFile(ftpFiles[0].getName());
}
// delegate the deletion of the local temp file to the delete task
// because of race conditions occurring on Windows
Delete mydelete = new Delete();
mydelete.bindToOwner(this);
mydelete.setFile(tempFile.getCanonicalFile());
mydelete.execute();
} catch (Exception e) {
throw new BuildException(e, getLocation());
}
return returnValue;
}
示例3: deleteFile
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private static void deleteFile(Project project, File file) {
Delete deleteTask = new Delete();
deleteTask.setProject(project);
deleteTask.setTaskName("delete file");
deleteTask.setFile(file);
deleteTask.execute();
}
示例4: deleteTmpFile
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private static void deleteTmpFile(File tmpFile) {
final Delete del = new Delete();
del.setFile(tmpFile);
del.execute();
}
示例5: transform
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* transformation
* @throws BuildException exception if something goes wrong with the transformation.
*/
public void transform() throws BuildException {
checkOptions();
Project project = task.getProject();
TempFile tempFileTask = new TempFile();
tempFileTask.bindToOwner(task);
xsltTask.setXslResource(getStylesheet());
// acrobatic cast.
xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
File outputFile;
if (FRAMES.equals(format)) {
String tempFileProperty = getClass().getName() + String.valueOf(counter++); //NOSONAR
File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), project
.getProperty("java.io.tmpdir"));
tempFileTask.setDestDir(tmp);
tempFileTask.setProperty(tempFileProperty);
tempFileTask.execute();
outputFile = new File(project.getProperty(tempFileProperty));
} else {
outputFile = new File(toDir, "junit-noframes.html");
}
xsltTask.setOut(outputFile);
XSLTProcess.Param paramx = xsltTask.createParam();
paramx.setProject(task.getProject());
paramx.setName("output.dir");
paramx.setExpression(toDir.getAbsolutePath());
configureForRedirectExtension();
final long t0 = System.currentTimeMillis();
try {
xsltTask.execute();
} catch (Exception e) {
throw new BuildException("Errors while applying transformations: " + e.getMessage(), e);
}
final long dt = System.currentTimeMillis() - t0;
task.log("Transform time: " + dt + "ms");
if (format.equals(FRAMES)) {
Delete delete = new Delete();
delete.bindToOwner(task);
delete.setFile(outputFile);
delete.execute();
}
}