import java.io.*;
class CopyFile
{
public static void main(String args[])
throws IOException
{
int i;
FileInputStream fin=null;
FileOutputStream fout=null;
if(args.length!=2)
{
System.out.println("Mention the name of Source and Destination File");
return;
}
try{
fin=new FileInputStream(args[0]);
fout=new FileOutputStream(args[1]);
do{
i=fin.read();
if(i!=-1) fout.write(i);
}while(i!=1);
} catch (IOException exc)
{System.out.println("I/O Error Exception exc"+exc);
}
finally {
try{
if(fin !=null) fin.close();
}catch (IOException exc){
System.out.println("Error Closing the File");}
try {
if(fout !=null) fout.close();
}catch (IOException exc)
{System.out.println("Error Closing the File");
}
}
}
}
Au-dessus des copies de codage des données à partir du fichier source au fichier de destination. PROBLEME: pourquoi la méthode Close() ne peut-elle pas fermer le fichier ouvert? Je suis un débutant et je souhaite apprendre la programmation. THK EN AVANT !!écriture d'un fichier à l'aide FileOutput flux
Vous ferme FileOutputStream non File ... – amkz
'Close()' est de fermer la ressource, 'FileOutputStream' dans votre cas – Ramanlfc