/*
* Autor: Juan Antonio Ripoll
*
* REALIZA UN PROGRAMA EN JAVA QUE MUESTRE LOS FICHEROS DE UN DIRECTORIO. EL
* NOMBRE (DEL FICHERO O DIRECTORIO) SE PASARÁ COMO PARÁMETRO.
*/
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Main
{
public static void main(String[] args) throws IOException
{
String path_file = null;
if (args.length != 1)
{
System.out.print("Introduzca la ruta de un directorio/archivo: ");
InputStreamReader c = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(c);
path_file = in.readLine();
}
else
path_file = args[0];
File archivo = new File( path_file );
if (archivo.isDirectory())
{
File[] archivos = archivo.listFiles();
for (File a : archivos) {
System.out.println(a.getName());
}
}
}
}
Thursday, December 12, 2013
Ejercicio 1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment