Bonsoir à tous,

je cherche à écrire puis lire dans un fichier, voici mon code

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
public static void ecritureByte(byte[] tabByte, String fic) throws Exception
	{
		FileOutputStream fos=null;
		try
		{
			fos = new FileOutputStream(fic);
			BufferedOutputStream fils = new BufferedOutputStream(fos);
			DataOutputStream dataOut = new DataOutputStream(fils);
 
			for(int i =0; i<tabByte.length; i++)
			{	
			            System.out.println(new Byte(tabByte[i]).intValue());
				dataOut.writeByte(tabByte[i]);
			}
 
			dataOut.close();
			fils.close();
			fos.close();
 
		}
		catch(Exception e)
		{	}
 
	}
 
public static String lectureByte(String fic) throws Exception
	{
		FileInputStream fis=null;
		System.out.println("----------------------");
		try
		{
			fis = new FileInputStream(fic);
			BufferedInputStream buf = new BufferedInputStream(fis);
			DataInputStream dataIn = new DataInputStream(buf);
 
	                         while(dataIn.read()!=-1)
			{
				System.out.println(dataIn.readByte());
			}
 
			dataIn.close();
			buf.close();
			fis.close();
 
		}
		catch(FileNotFoundException e)
		{	}
Voici ce que je récupère :
7
97
49
12
113
-17
5
0
----------------------
97
12
-17
0
est-ce que quelqu'un saurait m'expliquer le problème s'il vous plait, trouver où est l'erreur pour me l'expliquer!!!

Merci d'avance pour vos réponses