Bjr, voici mon code pour ecrire ce qu'il y a ds le fichier un dans le ficher2

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
 
 
public class filestreamtest {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
 
        FileInputStream fis;
        FileOutputStream fos;
 
        try{
 
            fis = new FileInputStream (new File("test.txt"));
            fos = new FileOutputStream (new File("test2.txt"));
 
            byte [] buf= new byte [8];
 
            int n=0;
 
            while ((n=fis.read(buf))>= 0)
            {
                fos.write(buf);
 
                for (byte bit: buf)
                {
                    System.out.println("\t" + bit + "("+ (char)bit+ ")");
 
 
                }
 
                System.out.println("hello charaf");
            }
 
            fis.close();
            fos.close();
            System.out.println("Copy finished");
 
 
    }catch (FileNotFoundException e) {
        e.printStackTrace();
}
    catch (IOException e){
e.printStackTrace();        
    }
 
    }
 
}
et la quand je luis donne par exemple test comme ça
Salut c'est IO
normalement je devrai avoir la meme chose dans test2 mais la j'ai:
Salut c'est IOc'
...

Aidez moi svp...Merci