Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/06/2005, 07:55
Avatar de stock
stock
 
Fecha de Ingreso: junio-2004
Ubicación: Monterrey NL
Mensajes: 2.390
Antigüedad: 19 años, 10 meses
Puntos: 53
Con la Clase File contiene un metodo que se llama mkdirs, con el cual creas el directorio con el path que especificaste al instanciar la clase FILE, aqui un ejemplo:

Código PHP:
/*
 * Author: Crysfel Villa
 * Created: Wednesday, June 29, 2005 8:41:39 AM
 * Modified: Wednesday, June 29, 2005 8:41:39 AM
 */

import java.io.*;

public class 
FileSystem
{
    private 
String path;
    private 
File f;
    private static final 
int tiempoEspera 10;
        
    public 
FileSystem(String p){
        
path p;
    }
    
    public 
boolean mkdir(String carp){
        
= new File(path "/" carp);
        if(!
f.exists()){
            if (!
f.mkdirs()) {
                try {
                    
Thread.sleep(tiempoEspera);
                    return 
f.mkdirs();
                } catch (
InterruptedException ex) {
                    return 
f.mkdirs();
                }
            }
        }else{
            
System.out.println("El directorio ya existe :(");
            return 
false;
        }
        return 
true;
    }
    
    public static 
void mainString [] args throws IOException
    
{
        
FileSystem fs = new FileSystem("c:");
        if(
fs.mkdir("dir1")){
            
System.out.println("creado con existo :)");
        }else{
            
System.out.println("no se pudo crear el directorio :(");
        }
    }