source: ether_eccad/trunk/ECCAD_INTERFACE/WEB-INF/src/org/medias/eccad/persistance/GestionFichier.java @ 68

Last change on this file since 68 was 68, checked in by cbipsl, 14 years ago

commit v1 eccad

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1package org.medias.eccad.persistance;
2
3import java.io.File;
4import java.io.FileInputStream;
5import java.io.FileOutputStream;
6import java.io.IOException;
7import java.io.InputStream;
8import java.io.OutputStream;
9
10
11import org.medias.eccad.helpers.LoggerPerso;
12import org.medias.eccad.metier.TempPictureDeleter;
13
14public class GestionFichier {
15        public void effacerFichier(String path) {
16                File fichier = new File(path);
17                fichier.delete();
18        }
19       
20        public void effacerFichierAncien(String path) {
21                TempPictureDeleter deleteur = new TempPictureDeleter();
22                deleteur.deleteFiles(path);
23        }
24       
25        public void copy(String source, String destination) {
26                InputStream in = null;
27        OutputStream out =  null;
28       
29        int c=0;
30       
31        try {
32         if (source != null) in=new FileInputStream(source);
33         if (destination != null) out=new FileOutputStream(destination);
34         while ((c=in.read())!=-1) out.write(c);
35         in.close();
36         out.close();
37        } catch (IOException e) {
38         //system.out.println(e.toString());
39        } 
40        }
41       
42        public void deplace(String source, String destination) {
43                File fsource = new File(source);
44                if (!fsource.exists())
45                        LoggerPerso.log(GestionFichier.class, LoggerPerso.WARN, "fichier source non existant : " + source);
46                File fdestination = new File(destination);
47               
48                if (!fsource.renameTo(fdestination))
49                        LoggerPerso.log(GestionFichier.class, LoggerPerso.ERROR, "impossible de copier la legende") ;
50               
51                LoggerPerso.log(GestionFichier.class, LoggerPerso.INFO, "source : " + source + "\ndestination : " + destination) ;
52        }
53       
54        public void creerDossier(String dossier) {
55                File fdossier = new File(dossier);
56                fdossier.mkdir();
57        }
58}
Note: See TracBrowser for help on using the repository browser.