Example usage for org.springframework.util FileSystemUtils deleteRecursively

List of usage examples for org.springframework.util FileSystemUtils deleteRecursively

Introduction

In this page you can find the example usage for org.springframework.util FileSystemUtils deleteRecursively.

Prototype

public static boolean deleteRecursively(@Nullable Path root) throws IOException 

Source Link

Document

Delete the supplied File - for directories, recursively delete any nested directories or files as well.

Usage

From source file:org.fatal1t.forexapp.spring.Application.java

public static void main(String[] args) throws JMSException, InterruptedException {
    // Clean out any ActiveMQ data from a previous run
    FileSystemUtils.deleteRecursively(new File("activemq-data"));

    // Launch the application
    ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
    log.info("Session is loaded");

    APIStreamingAdapter ad = context.getBean(APIStreamingAdapter.class);
    ad.start();//from  www  . j  a  v a2s  .co  m
    // TODO code application logic here
}

From source file:io.fabric8.quickstarts.activemq.App.java

public static void main(String[] args) {
    // Clean out any ActiveMQ data from a previous run
    FileSystemUtils.deleteRecursively(new File("activemq-data"));

    // Launch the application
    ConfigurableApplicationContext context = SpringApplication.run(App.class, args);

    // Send a message
    MessageCreator messageCreator = new MessageCreator() {
        @Override//from   w  w w.  j  a va 2s.c  o m
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage("<hello>world!</hello>");
        }
    };
    JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
    System.out.println("Sending a new message.");
    jmsTemplate.send(destination, messageCreator);
}

From source file:nz.co.edmi.servicemixdemo.TestableRouteTest.java

@Before
public void cleanUp() {
    FileSystemUtils.deleteRecursively(new File(src));
    FileSystemUtils.deleteRecursively(new File(dest));
}

From source file:org.fatal1t.forexapp.spring.Receiver.java

/**
 * When you receive a message, print it out, then shut down the application.
 * Finally, clean up any ActiveMQ server stuff.
 *///from w  ww  .  j ava 2s  .c om
@JmsListener(destination = "mailbox-destination", containerFactory = "myJmsContainerFactory")
public void receiveMessage(String message) {
    System.out.println("Received <" + message + ">");
    context.close();
    FileSystemUtils.deleteRecursively(new File("activemq-data"));
}

From source file:eu.eidas.node.auth.metadata.EidasNodeMetadataGeneratorTest.java

@AfterClass
public static void removeDir() {
    FileSystemUtils.deleteRecursively(new File(FILEREPO_DIR_WRITE));
}

From source file:org.jboss.examples.activemq.KahaDBFileDeleteProcessStrategy.java

@Override
public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange,
        GenericFile<T> file) throws Exception {
    String kahaDb = exchange.getIn().getHeader("ActiveMQKahaDB", String.class);
    boolean drained = exchange.getIn().getHeader("ActiveMQKahaDBDrained", false, boolean.class);
    if (drained && kahaDb != null && !kahaDb.trim().equals("")) {
        log.info(String.format("Removing KahaDB [%s].", kahaDb));
        FileSystemUtils.deleteRecursively(new File(kahaDb));
        super.commit(operations, endpoint, exchange, file);
    }//from w ww  .jav a 2  s  .  c  o  m
}

From source file:org.openspaces.usm.USMRollingFileAppenderTailerTest.java

@Before
public void before() throws Exception {

    // Where the logs will go.
    final File logDir = new File(logsDirectory);

    FileSystemUtils.deleteRecursively(logDir);
    logDir.mkdirs();/*from w  w w  .  ja v a2  s. c o m*/

    final File logFile = new File(logDir,
            String.format("%s%s", System.getProperty("file.separator"), LOG_FILENAME));

    // Create a new pattern layout with our requested log pattern.
    final PatternLayout pl = new PatternLayout(LOG_PATTERN);

    rfp = new RollingFileAppender(pl, logFile.getCanonicalPath(), true);

    // We want the logger to flush its output to the log file
    // stream immediately; if you don't have this set, then
    // Log4j will buffer the log file output.
    rfp.setImmediateFlush(true);
    rfp.setBufferedIO(false);
    rfp.setBufferSize(LOG_IO_BUFFER_SIZE_BYTES);

    // Set the Max number of files and max size of each log
    // file to keep around.
    rfp.setMaxBackupIndex(MAX_LOG_BACKUP_FILES);
    rfp.setMaxFileSize(MAX_LOG_FILE_SIZE);

    // Set the default level of this logger.
    logger.setLevel(Level.INFO);
    // This logger will use the rolling appender.
    logger.addAppender(rfp);

    logger.getAllAppenders();

    logger.info("Log directory: " + logDir.getAbsolutePath());

}

From source file:org.cfr.capsicum.test.AbstractSimpleCayenneJUnitTests.java

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    FileSystemUtils.deleteRecursively(WORK_HOME);
    WORK_HOME.mkdirs();
}

From source file:org.openspaces.usm.USMRollingFileAppenderTailerTest.java

@After
public void after() {
    if (rfp != null) {
        rfp.close();
    }
    FileSystemUtils.deleteRecursively(new File(logsDirectory));
}