First specify the path and directory name
File dir=new File("Path to base dir");
if(!dir.exists){
dir.mkdir();}
// then generate the file name
String fileName="generate required fileName";
File tagFile=new File(dir,fileName+".txt");
if(!tagFile.exists()){
tagFile.createNewFile();
}
source
share