1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public boolean createFolder(String adress)
{
File f = new File(adress);
try{
if(!f.exists()){f.mkdirs();}
}
catch(Throwable e)
{e.printStackTrace();return false;}
return true;
}
public boolean createFile(String adress)
{
File f = new File(adress);
try{
if(!f.exists()){f.createNewFile();}
}
catch(IOException e)
{e.printStackTrace();return false;}
return true;
}
public boolean writeFile(String folder, String file, String text)
{
String adressFile = folder + adress;
if(creatFolder(folder) && createFile(adressFile))
{
try{
FileWriter fw = new FileWriter(adressedufichier, false);
BufferedWriter output = new BufferedWriter(fw);
output.write(texte);
output.flush();
output.close();
}catch(IOException e){e.printStackTrace();return false;}
}
else{return false;}
return true;
} |
Partager