Salve a tutti,
ho un problema con il salvataggio di un array di byte in un file XML (quindi lo devo salvare come stringa):
1-genero un array di byte
2-costruisco una stringa a partire dall'array
3-inserisco la stringa nel file XML
A questo punto dovrei estrarre l'array di byte dalla stringa ed è qui che sorge il problema...
Ecco i due array di byte:codice://Genero un array di 128 bit SecureRandom _sr = SecureRandom.getInstance("SHA1PRNG"); byte[] _b = _sr.generateSeed(16); //Ricostruisco la stringa a partire dall'array di byte String _s = new String(_b); //Estraggo l'array di byte dalla stringa byte[] _t = new byte[_s.getBytes().length]; for(int i =0;i<_t.length;i++) { _t[i] = _s.getBytes()[i]; } System.out.println(); for(int j =0;j<_b.length;j++) { System.out.print(_b[j]); } System.out.println(); for(int j =0;j<_t.length;j++) { System.out.print(_t[j]); } System.out.println();
0116-64-62114-65-22-110-69113-6411433450-12
0116-17-65-67-17-65-67114-17-65-67-22-110-69113-17-65-6711433450-17-65-67
Perchè i due array sono diversi???
e poi perchè se ricostruisco le due stringhe sono identiche???
Grazie in anticipo

Rispondi quotando