Example usage for java.io File list

List of usage examples for java.io File list

Introduction

In this page you can find the example usage for java.io File list.

Prototype

public String[] list() 

Source Link

Document

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

Usage

From source file:org.apache.camel.example.pojo_messaging.CamelContextTest.java

@Test
public void testCheckFiles() throws Exception {
    // wait a little for the files to be picked up and processed
    Thread.sleep(5000);//from   ww w.j  a  va  2  s  .c  o m

    File file = new File("target/messages/emea/hr_pickup");
    assertTrue("The pickup folder should exists", file.exists());
    assertEquals("There should be 1 dumped files", 1, file.list().length);
    file = new File("target/messages/amer/hr_pickup");
    assertTrue("The pickup folder should exists", file.exists());
    assertEquals("There should be 2 dumped files", 2, file.list().length);
}

From source file:com.thoughtworks.go.remote.work.artifact.ArtifactsPublisher.java

private boolean isMetadataFolderEmpty(File pluggableArtifactFolder) {
    return pluggableArtifactFolder != null && pluggableArtifactFolder.list().length == 0;
}

From source file:com.jejking.hh.nord.corpus.FetchedDruckSachenProcessor.java

public void preProcessFetchedDocuments(final File inputDirectory, final File outputDirectory,
        ImmutableMap<URL, Optional<LocalDate>> urlDateMap) {
    Observable.from(inputDirectory.list()).map(new Func1<String, File>() {

        @Override/*from   w  ww  .  j  a v a  2s  . c om*/
        public File call(String fileName) {
            return new File(inputDirectory.getPath() + File.separator + fileName);
        }

    }).map(new AllrisHtmlToRawDrucksache(urlDateMap)).observeOn(Schedulers.io())
            .subscribe(new Action1<Optional<RawDrucksache>>() {

                @Override
                public void call(Optional<RawDrucksache> rawDrucksache) {
                    if (rawDrucksache.isPresent()) {
                        File destination = new File(outputDirectory + File.separator
                                + Hex.encodeHexString(
                                        rawDrucksache.get().getDrucksachenId().getBytes(Charsets.UTF_8))
                                + ".dat");
                        if (!destination.exists()) {
                            try (ObjectOutputStream oos = new ObjectOutputStream(
                                    new BufferedOutputStream(new FileOutputStream(destination)))) {
                                oos.writeObject(rawDrucksache.get());
                                counter.addAndGet(1);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        } else {
                            System.err.println(
                                    "Duplicate drucksachen-id: " + rawDrucksache.get().getDrucksachenId());
                        }
                    }

                }

            });

    System.out.println("Written " + counter.get() + " data sets");
}