Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.util.ArrayList;

public class Main {
    public static File getFicheroDirectorio(String directorio_carga, String fileName) {
        File ficheros[] = getFilesDirectorio(directorio_carga);
        for (int i = 0; i < ficheros.length; i++) {
            if (ficheros[i].getName().equals(fileName))
                return ficheros[i];
        }
        return null;
    }

    public static File[] getFilesDirectorio(String nombreDirectorio) {
        File directorio = new File(nombreDirectorio);
        File[] files = directorio.listFiles();
        ArrayList<File> filtro = new ArrayList<File>();
        if (files != null)
            for (int i = 0; i < files.length; i++) {
                if (files[i].isFile()) {
                    filtro.add(files[i]);
                }
            }
        return filtro.toArray(new File[filtro.size()]);
    }
}