Bonjour,

Pourriez vous m'aider sur la conversion d'un byte e hexadecimal svp...
J'ai un petit soucis entre le départ et l'arrivée :

Voici le code permettant de tranformer le contenu d'un fichier en hexadecimal :

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
 
StringBuffer retour = new StringBuffer();
FileInputStream f = new FileInputStream(getFichier());
 
int car;
int i=0;
while ((car=f.read())>=0)
if (Integer.toHexString(car).length() !=2)
{
	if (i++<40) System.out.println("0"+Integer.toHexString(car));
	retour.append("0" + Integer.toHexString(car));
}
else
{
	if (i++<40) System.out.println(Integer.toHexString(car));
	retour.append(Integer.toHexString(car));
}
Voici les 40 1ers caractères :
[code]
50
4b
03
04
14
00
00
00
08
00
90
61
c8
34
f3
aa
f4
8d
cb
[code]

Mon code permettant de recuperer ce code à partir de la base :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
blob = (byte[]) q.getResultat().next().get(0);
 
for (int i=0; i<40; i++)
	System.out.println(Integer.toHexString(new Byte(blob[i]).intValue()));
Et la ... surprise... j'ai :

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
 
50
4b
3
4
14
0
0
0
8
0
ffffff90
61
ffffffc8
34
fffffff3
ffffffaa
fffffff4
ffffff8d
ffffffcb
Quelqu'un pourrait m'expliquer svp, parce que là je m'arrache les cheveux !

Merci