Department of Mathematics and Computer Sciencewww.univ-soukahras.dz/en/dept/mi |
2 votes
|
how to create a file and write to a file in java ? and do I check if a file exists ?? |
Asked on 13:45, Sunday 8 May 2016 By houssem djefaflia |
answers (4)
Answer (1)
1 votes
|
// instruction pour creé un fichier |
Answered on 14:56, Sunday 8 May 2016 by Aterrai Zakaria |
Answer (2)
1 votes
|
//check if a file exists File file = new File("path/nom_fichier.txt"); |
Answered on 15:00, Sunday 8 May 2016 by Aterrai Zakaria |
Answer (3)
2 votes
|
try{ File file = new File("path/nom_fichier.txt"); if(!file.exists()){ file.createNewFile(); // do some work you need }else{ System.out.println("File already exists"); // do some work you need } }catch(IOException ex){ // handling exception or ex.printStackTrace(); }
|
Answered on 16:28, Sunday 8 May 2016 by fateh bensadi (13 points) |
Answer (4)
1 votes
|
c'est mieux d'utiliser la sérialisation d'objet en java puisque tu crie en fin un fichier d'objet . c'est une class a implementer facilement . |
Answered on 20:34, Sunday 8 May 2016 by khaled amirat |