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:FileTreeFrame.java

public int getIndexOfChild(Object parent, Object child) {
    File directory = (File) parent;
    File file = (File) child;
    String[] children = directory.list();
    for (int i = 0; i < children.length; i++) {
        if (file.getName().equals(children[i])) {
            return i;
        }//from   w  w w .j av a2s.  co m
    }
    return -1;

}

From source file:azkaban.reportal.util.StreamProviderLocal.java

public String[] getFileList(String pathString) throws IOException {
    File file = new File(pathString);

    if (file.exists() && file.isDirectory()) {
        return file.list();
    }//from ww  w .j a v a2s . c  o m

    return new String[0];
}

From source file:com.mindcognition.mindraider.install.Installer.java

/**
 * Process only files under dir.//www  .j  a  v a2 s  .c  o m
 * 
 * @param dir
 *            the file
 * @throws Exception
 *             a generic exception
 */
public static void internationalizationUpgradeTo511(File dir) throws Exception {
    String fromFile = dir.getPath();
    if (dir.isDirectory()) {
        logger.debug("Dir: " + fromFile);
        StatusBar.setText(" Directory: ", fromFile, 70);

        if (logger.isDebugEnabled()) {
            logger.debug("internationalizationUpgradeTo511()");
        }

        String[] children = dir.list();
        for (String child : children) {
            internationalizationUpgradeTo511(new File(dir, child));
        }
    } else {
        logger.debug("File: " + fromFile);
        StatusBar.setText(" File: ", fromFile, 70);
        if (fromFile.endsWith(".xml")) {
            internationalizationUpgradeTo511(fromFile);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("internationalizationUpgradeTo511()");
        }
    }
}

From source file:de.metanome.smart_data_cat.fd.FDAlgorithmTest.java

/**
 * @throws java.lang.Exception//from   ww  w .  j a  v  a 2 s .  c o m
 */
@Before
public void setUp() throws Exception {
    taneAlgorithm = new TaneAlgorithm();

    ConfigurationSettingFileInput fileInputSettings = new ConfigurationSettingFileInput(
            "src/test/resources/WDC_planets.csv", true, ',', '\"', '\\', false, true, 0, true, true);

    String path = "D:/Dokumente/DPDC/Data_FunctionalDependencies";
    inputs = new ArrayList<DefaultFileInputGenerator>();
    File folder = new File(path);
    for (String file : folder.list()) {
        ConfigurationSettingFileInput fileInput = new ConfigurationSettingFileInput(path + "/" + file, true,
                ',', '\"', '\\', false, true, 0, false, true);

        inputs.add(new DefaultFileInputGenerator(fileInput));
    }

    fileInputGenerator = new DefaultFileInputGenerator(fileInputSettings);
}

From source file:de.uzk.hki.da.cb.ShortenFileNamesAction.java

private void deleteEmptyDirsRecursively(String path) {
    String dirPath = FilenameUtils.getFullPath(path);
    File dir = new File(dirPath);
    if (dir.isDirectory() && dir.list().length == 0) {
        dir.delete();/*  ww w.ja va2  s.com*/
        deleteEmptyDirsRecursively(dir.getAbsolutePath());
    }
}

From source file:at.modalog.cordova.plugin.cache.Cache.java

public boolean deleteDir(File dir) {
    if (dir != null && dir.isDirectory()) {
        String[] children = dir.list();
        for (int i = 0; i < children.length; i++) {
            boolean success = deleteDir(new File(dir, children[i]));
            if (!success) {
                return false;
            }//from  ww w . jav a2s  .co m
        }
    }
    return dir.delete();
}

From source file:eu.cloud4soa.soa.jaxrs.test.SemanticAppInitializer.java

public void initialize() {

    try {//w  w  w  .  ja  v  a2s . c om
        String developerUserDir = "applicationProfiles";
        URL resource = scanPackage(developerUserDir);
        String protocol = resource.getProtocol();
        if (protocol.equals("file")) {
            File file = new File(resource.getFile());
            if (file.isDirectory()) {
                String[] list = file.list();
                for (String fileName : list) {
                    String applicationTurtleProfile = loadTurtleFileIntoString(developerUserDir, fileName);
                    logger.info("Loaded application profile: " + fileName);
                    storeTurtleApplicationProfile(applicationTurtleProfile, developerUriId);
                }
            }
        }
    } catch (IOException ex) {
        logger.error("Error during the creation of the Application profiles", ex);
    }
}

From source file:org.mwolff.generator.commands.MergeTemplateTest.java

@Test
public void mergeTemplateWithConfiguration() throws Exception {

    configuration.setConfiguration("src/test/resources/configuration.test.properties");
    readConfiguration.execute(configuration);
    configuration.setXmlfile("src/test/resources/class.xml");
    readClassStructure.execute(configuration);
    solveReferences.execute(configuration);
    mergeTemplate.execute(configuration);

    String mergeString = configuration.getMergeString();
    assertThat(mergeString, notNullValue());
    File file = new File(configuration.getActualOutputPath() + "/" + configuration.getOutputFile());
    assertThat(configuration.getOutputFile().lastIndexOf(".java") > 0, is(true));
    assertThat(file.exists(), is(true));

    File dir = new File(configuration.getActualOutputPath());
    String[] entries = dir.list();
    for (String s : entries) {
        File currentFile = new File(dir.getPath(), s);
        currentFile.delete();// ww w.ja  va 2  s . c  om
    }

    dir.delete();
    dir = new File(configuration.getBasepath() + "/org/mwolff");
    dir.delete();
    dir = new File(configuration.getBasepath() + "/org");
    dir.delete();
}

From source file:net.itransformers.idiscover.v2.core.listeners.GraphmlFileLogGroovyDiscoveryListenerTestCase.java

public void nodeDiscoverer() throws IOException, JAXBException {
    System.out.println("->>>>>>>" + new File(".").getAbsolutePath());
    File projectPath = createTempDirectory();
    GraphmlFileLogGroovyDiscoveryListener listener = new GraphmlFileLogGroovyDiscoveryListener();
    listener.setProjectPath(projectPath.getAbsolutePath());
    String labelDirName = ProjectConstants.labelDirName;
    listener.setLabelDirName(labelDirName);
    String graphmlDirName = "undirected";
    listener.setGraphmlDirName(graphmlDirName);
    InputStream groovyIs = new FileInputStream("iDiscover/conf/groovy/RawData2GraphmlTransformer.groovy");
    File groovyPath = new File(projectPath, "iDiscover/conf/groovy");
    groovyPath.mkdirs();/*  w  w w . j a va  2  s .c om*/
    FileUtils.copyInputStreamToFile(groovyIs, new File(groovyPath, "RawData2GraphmlTransformer.groovy"));
    listener.setRawData2GraphmlGroovyTransformer("iDiscover/conf/groovy/RawData2GraphmlTransformer.groovy");
    NodeDiscoveryResult discoveryResult = new NodeDiscoveryResult("123", null);
    InputStream is = this.getClass().getResourceAsStream("/bfogal54-peer.xml");
    DiscoveredDeviceData deviceData = JaxbMarshalar.unmarshal(DiscoveredDeviceData.class, is);
    discoveryResult.setDiscoveredData("deviceData", deviceData);
    listener.nodeDiscovered(discoveryResult);
    File labelDir = new File(projectPath, labelDirName);
    File graphmlDir = new File(labelDir, graphmlDirName);
    String[] generatedFiles = graphmlDir.list();
    Assert.assertEquals(generatedFiles.length, 1);

}

From source file:CreatingTreeModel.java

public int getIndexOfChild(Object parent, Object child) {
    File directory = (File) parent;
    File directoryMember = (File) child;
    String[] directoryMemberNames = directory.list();
    int result = -1;

    for (int i = 0; i < directoryMemberNames.length; ++i) {
        if (directoryMember.getName().equals(directoryMemberNames[i])) {
            result = i;/*www .  j a v a 2  s.c om*/
            break;
        }
    }

    return result;
}