My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.lineadecodigo.java.file;

import java.io.File;

/**
* @file ListarContenidoDirectorio.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 26-diciembre-08
* @url http://lineadecodigo.com/2008/12/26/listar-un-directorio-con-java/
* @description Lista el contenido de un directorio mediante Java
*/


public class ListarContenidoDirectorio {


public static void main(String[] args) {

String sDirectorio = "c:\\datos";
File f = new File(sDirectorio);

if (f.exists()){
// Recuperamos la lista de ficheros
File[] ficheros = f.listFiles();
for (int x=0;x<ficheros.length;x++){
System.out.println(ficheros[x].getName());
}
} else{
System.out.println("No existe ese directorio");
}


}

}

Change log

r54 by vcuervo on Dec 26, 2008   Diff
Listar el contenido de un directorio con
Java.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 808 bytes, 36 lines
Powered by Google Project Hosting