Java: Vérifier si le nom de fichier est accepté par windows

Author:

 fichier, java
{filelink=12398}


public class Fichier_N
 {

 /*
  * Ce programme modifie le nom d'un fichier pour l'adapter à Windows
  */
public static String adapter_NomFichier(String nom_fichier)
 {
  // Remplacer les caractères spéciaux par un tiret
 return nom_fichier.replaceAll("[:\/*?|<>]", "-");
 }
public static void main(String args[]) throws Exception
{  

 System.out.println("Le nom de votre fichier à été modifié par==> " + adapter_NomFichier("test?de <*mp.txt"));   

}  

} 	

Leave a Reply

Your email address will not be published. Required fields are marked *