当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.deleteFile方法代码示例

本文整理汇总了Java中org.apache.camel.util.FileUtil.deleteFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.deleteFile方法的具体用法?Java FileUtil.deleteFile怎么用?Java FileUtil.deleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.FileUtil的用法示例。


在下文中一共展示了FileUtil.deleteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doReleaseExclusiveReadLock

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
protected void doReleaseExclusiveReadLock(GenericFileOperations<File> operations,
                                          GenericFile<File> file, Exchange exchange) throws Exception {
    if (!markerFile) {
        // if not using marker file then nothing to release
        return;
    }

    boolean acquired = exchange.getProperty(asReadLockKey(file, Exchange.FILE_LOCK_FILE_ACQUIRED), false, Boolean.class);

    // only release the file if camel get the lock before
    if (acquired) {
        String lockFileName = exchange.getProperty(asReadLockKey(file, Exchange.FILE_LOCK_FILE_NAME), String.class);
        File lock = new File(lockFileName);

        if (lock.exists()) {
            LOG.trace("Unlocking file: {}", lockFileName);
            boolean deleted = FileUtil.deleteFile(lock);
            LOG.trace("Lock file: {} was deleted: {}", lockFileName, deleted);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:MarkerFileExclusiveReadLockStrategy.java

示例2: testSftpTempFileNoStartingPath

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Test
public void testSftpTempFileNoStartingPath() throws Exception {
    if (!canTest()) {
        return;
    }

    template.sendBodyAndHeader("sftp://localhost:" + getPort()
            + "/?username=admin&password=admin&tempFileName=temp-${file:name}", "Hello World", Exchange.FILE_NAME, "hello.txt");

    File file = new File("hello.txt");
    assertTrue("File should exist: " + file, file.exists());
    assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));

    // delete file when we are done testing
    FileUtil.deleteFile(file);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:SftpProduceTempFileTest.java

示例3: checkImage

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
protected void checkImage(MockEndpoint mock, int height, int width, String type, BarcodeFormat format) throws IOException {
    Exchange ex = mock.getReceivedExchanges().get(0);
    File in = ex.getIn().getBody(File.class);
    FileInputStream fis = new FileInputStream(in);

    // check image
    BufferedImage i = ImageIO.read(fis);
    IOHelper.close(fis);

    assertTrue(height >= i.getHeight());
    assertTrue(width >= i.getWidth());
    this.checkType(in, type);
    this.checkFormat(in, format);

    FileUtil.deleteFile(in);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:BarcodeTestBase.java

示例4: cleanUpTempFile

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
void cleanUpTempFile() {
    // cleanup temporary file
    try {
        if (tempFile != null) {
            FileUtil.deleteFile(tempFile);
            tempFile = null;
        }
    } catch (Exception e) {
        LOG.warn("Error deleting temporary cache file: " + tempFile + ". This exception will be ignored.", e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:FileInputStreamCache.java

示例5: deleteLockFiles

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private static void deleteLockFiles(File dir, boolean recursive, String endpointPath,
                                    GenericFileFilter filter, GenericFileFilter antFilter,
                                    Pattern excludePattern, Pattern includePattern) {
    File[] files = dir.listFiles();
    if (files == null || files.length == 0) {
        return;
    }

    for (File file : files) {

        if (file.getName().startsWith(".")) {
            // files starting with dot should be skipped
            continue;
        }

        // filter unwanted files and directories to avoid traveling everything
        if (filter != null || antFilter != null || excludePattern != null || includePattern != null) {
            if (!acceptFile(file, endpointPath, filter, antFilter, excludePattern, includePattern)) {
                continue;
            }
        }

        if (file.getName().endsWith(FileComponent.DEFAULT_LOCK_FILE_POSTFIX)) {
            LOG.warn("Deleting orphaned lock file: " + file);
            FileUtil.deleteFile(file);
        } else if (recursive && file.isDirectory()) {
            deleteLockFiles(file, true, endpointPath, filter, antFilter, excludePattern, includePattern);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:MarkerFileExclusiveReadLockStrategy.java

示例6: deleteLocalWorkFile

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
protected void deleteLocalWorkFile(Exchange exchange) {
    // delete local work file, if it was used (eg by ftp component)
    File local = exchange.getIn().getHeader(Exchange.FILE_LOCAL_WORK_PATH, File.class);
    if (local != null && local.exists()) {
        boolean deleted = FileUtil.deleteFile(local);
        log.trace("Local work file: {} was deleted: {}", local, deleted);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:GenericFileProcessStrategySupport.java

示例7: onFailure

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
public void onFailure(Exchange exchange) {
    // delete the file
    String name = exchange.getIn().getHeader(Exchange.FILE_NAME_PRODUCED, String.class);
    FileUtil.deleteFile(new File(name));

    // signal we have deleted the file
    LATCH.countDown();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:FileRollbackOnCompletionTest.java

示例8: deleteDir

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private static void deleteDir(Deque<File> deleteStack) {
    File f = deleteStack.pollLast();
    if (f != null) {
        if (f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (File child : files) {
                    deleteStack.addLast(child);
                }
            }
        }
        deleteDir(deleteStack);
        FileUtil.deleteFile(f);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:ZooKeeperTestSupport.java

示例9: addFileToTar

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private void addFileToTar(File source, File file, String fileName) throws IOException, ArchiveException {
    File tmpTar = File.createTempFile(source.getName(), null, parentDir);
    tmpTar.delete();
    if (!source.renameTo(tmpTar)) {
        throw new IOException("Could not make temp file (" + source.getName() + ")");
    }

    FileInputStream fis = new FileInputStream(tmpTar);
    TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, fis);
    TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source));
    tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);

    InputStream in = new FileInputStream(file);

    // copy the existing entries    
    ArchiveEntry nextEntry;
    while ((nextEntry = tin.getNextEntry()) != null) {
        tos.putArchiveEntry(nextEntry);
        IOUtils.copy(tin, tos);
        tos.closeArchiveEntry();
    }

    // Add the new entry
    TarArchiveEntry entry = new TarArchiveEntry(fileName == null ? file.getName() : fileName);
    entry.setSize(file.length());
    tos.putArchiveEntry(entry);
    IOUtils.copy(in, tos);
    tos.closeArchiveEntry();

    IOHelper.close(fis, in, tin, tos);
    LOG.trace("Deleting temporary file: {}", tmpTar);
    FileUtil.deleteFile(tmpTar);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:TarAggregationStrategy.java

示例10: addEntryToTar

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private void addEntryToTar(File source, String entryName, byte[] buffer, int length) throws IOException, ArchiveException {
    File tmpTar = File.createTempFile(source.getName(), null, parentDir);
    tmpTar.delete();
    if (!source.renameTo(tmpTar)) {
        throw new IOException("Cannot create temp file: " + source.getName());
    }

    FileInputStream fis = new FileInputStream(tmpTar);
    TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, fis);
    TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source));
    tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);

    // copy the existing entries    
    ArchiveEntry nextEntry;
    while ((nextEntry = tin.getNextEntry()) != null) {
        tos.putArchiveEntry(nextEntry);
        IOUtils.copy(tin, tos);
        tos.closeArchiveEntry();
    }

    // Create new entry
    TarArchiveEntry entry = new TarArchiveEntry(entryName);
    entry.setSize(length);
    tos.putArchiveEntry(entry);
    tos.write(buffer, 0, length);
    tos.closeArchiveEntry();

    IOHelper.close(fis, tin, tos);
    LOG.trace("Deleting temporary file: {}", tmpTar);
    FileUtil.deleteFile(tmpTar);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:TarAggregationStrategy.java

示例11: onDone

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Override
public void onDone(Exchange exchange) {
    FileUtil.deleteFile(new File(fileName));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:XsltBuilder.java

示例12: deleteFile

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
public boolean deleteFile(String name) throws GenericFileOperationFailedException {
    File file = new File(name);
    return FileUtil.deleteFile(file);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:FileOperations.java

示例13: after

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@After
public void after() {
    FileUtil.deleteFile(this.store);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:FileIdempotentConsumerCreateRepoTest.java

示例14: onComplete

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Override
public void onComplete(Exchange exchange) {
    LOG.debug("Deleting tar file on completion: {} ", this.fileToDelete);
    FileUtil.deleteFile(this.fileToDelete);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:TarAggregationStrategy.java

示例15: tearDown

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception {
    super.tearDown();

    FileUtil.deleteFile(testFile);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:S3ComponentFileTest.java


注:本文中的org.apache.camel.util.FileUtil.deleteFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。