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
|
InputStream in;
try {
// File_Image est mon FileChooser
in = new FileInputStream(File_Image.getSelectedFile());
// Destination
File dst = new File("Images/Medias/"+File_Image.getSelectedFile().getName());
// Création d'un nouveau fichier
dst.createNewFile();
OutputStream out = new FileOutputStream(dst);
// Transfert
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// Fermeture des flux
in.close();
out.close();
}
catch (FileNotFoundException e2) {}
catch (IOException e3){} |
Partager