referencecomment ajouter des dossiers dans le sous-répertoire java?
`String pathname = "C:/sata1/pm8/data/pmin/";`
String year ="UNKNOWN";
year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
String yearM = "UNKNOWN";
yearM = new SimpleDateFormat("yyyyMM").format(new Date());
String yearD ="UNKNOWN";
yearD =new SimpleDateFormat("yyyyMMdd").format(new Date());
pathname+=year+"/"+yearM+ "/"+yearD;
File directory;
directory = new File(pathname);
if (!directory.exists()){
directory.mkdirs();
}
C'est ce que j'ai essayé. Cela rend le répertoire et le sous-répertoire comme celui-ci C:\sata1\pm8\data\pmin\2017\201709\20170919
. Maintenant, je dois faire les 4 dossiers sous 20170919
.
Directory(sata1)
└── subDirectory(pm8)
└── subDirectory(data)
└── subDirectory(pmin)
└── subDirectory(year)
└── subDirectory(yearM)
└── subDirectory(yearD)
├── folder1
├── folder2
└── folder3 like this
quelle erreur vous faites face dans votre code? – Nidhi257
vous devez créer tous les répertoires qui sont absents étape par étape –
@ РоманДанилов non, vous n'avez pas. mkdirs crée tous les répertoires. – leonz