Java: Créer un fichier sur le disque dur

Author:

 fichier, méthode
Download

import java.io.*;
 
 
 
/**
 
 * Exemple de création d'un fichier
 *
 */
 
public class CreateFile
{
 
    public static void main(String[] arg) throws IOException {
 
 
 
        // Enumérer les noms passés en argument de ligne de commandes
 
        if (arg.length == 0) {
 
            System.err.println("Utilisation: CreateFile nomfichier1, nomfichier2");
 
            System.exit(1);
 
        }
 
 
 
        for (int i = 0; i< arg.length; i++)
        {
 
            // La méthode "createNewFile()" créé physiquement un fichier
            new File(arg[i]).createNewFile( );
 
        }
 
    }
 
}