1

I have a

Map nameANDbytes =  new HashMap<String, byte[]>();

How can I get that byte array out of map?

Lets say I put

 InputStream input = zipfile.getInputStream(zipentry);
 BufferedReader br = new BufferedReader(new InputStreamReader(input, "UTF-8"));
 nameANDbytes.put(fileName, br.toString().getBytes());

print is :

*.png
[B@1339e7aa

now I want to get values :

byte[] b = entry.getValue().toString().getBytes();

and it is

[B@1fb669c3

What's wrong?

Filburt
  • 17,626
  • 12
  • 64
  • 115
RedCollarPanda
  • 1,389
  • 1
  • 20
  • 40
  • 3
    _What's wrong_ Although not completely clear from your question, I would say the `br.toString().getBytes()` is wrong. `br.toString()` does not read your input. You are just getting a String representation of the `BufferedReader` and then you convert that string to a byte array. Perfectly valid code, but probably not what you were aiming for. – Robin Oct 18 '14 at 16:55

1 Answers1

1

I think you want

byte[] b = (byte[]) entry.getValue();
Jean-François Savard
  • 20,626
  • 7
  • 49
  • 76