[java] Pb bizarre à la création d'un fichier
Résolu/Fermé
Shino_
Messages postés
3
Date d'inscription
mercredi 20 mai 2009
Statut
Membre
Dernière intervention
20 mai 2009
-
20 mai 2009 à 19:55
Shino_ Messages postés 3 Date d'inscription mercredi 20 mai 2009 Statut Membre Dernière intervention 20 mai 2009 - 20 mai 2009 à 20:22
Shino_ Messages postés 3 Date d'inscription mercredi 20 mai 2009 Statut Membre Dernière intervention 20 mai 2009 - 20 mai 2009 à 20:22
A voir également:
- [java] Pb bizarre à la création d'un fichier
- Comment réduire la taille d'un fichier - Guide
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Fichier rar - Guide
- Comment ouvrir un fichier epub ? - Guide
1 réponse
Shino_
Messages postés
3
Date d'inscription
mercredi 20 mai 2009
Statut
Membre
Dernière intervention
20 mai 2009
20 mai 2009 à 20:22
20 mai 2009 à 20:22
Probléme résolu... en fait en créant un nouveau temp file, java génére une série de caractére aléatoire à la fin pour être sur de ne rien écraser... afin d'éviter ce probléme il faut forcer le nouveau nom en quelque sorte...
la ligne que j'ai changer est en gras si ca en interesse quelques uns..
public class test {
public static void newTempFile (String filename, File temp) throws IOException {
String s = new String();
s = filename;
File ff = new File("/home/shino/Bureau/Lol/"+filename);
File fileTest=new File("/home/shino/Bureau/Lol/"+filename);
if (fileTest.exists()==true) { System.out.println("Existe déjà :-O)");}
if (temp.exists()==true){
temp = new File("/home/shino/Bureau/Lol/");
File.createTempFile(s, ".tmp", temp).renameTo(ff); //throw IOException
}
else System.out.println("yata");
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String s = new String();
s="youhou";
File temp=new File("/home/shino/Bureau/Lol");
/*moveTempFile("Jaaea",temp);*/
newTempFile(s,temp);
}
la ligne que j'ai changer est en gras si ca en interesse quelques uns..
public class test {
public static void newTempFile (String filename, File temp) throws IOException {
String s = new String();
s = filename;
File ff = new File("/home/shino/Bureau/Lol/"+filename);
File fileTest=new File("/home/shino/Bureau/Lol/"+filename);
if (fileTest.exists()==true) { System.out.println("Existe déjà :-O)");}
if (temp.exists()==true){
temp = new File("/home/shino/Bureau/Lol/");
File.createTempFile(s, ".tmp", temp).renameTo(ff); //throw IOException
}
else System.out.println("yata");
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String s = new String();
s="youhou";
File temp=new File("/home/shino/Bureau/Lol");
/*moveTempFile("Jaaea",temp);*/
newTempFile(s,temp);
}