getAvatar() ... and then?

Hi everyone,

I’‘m a little frustrated at the moment, I’'m just trying to save the avatar from a contact into a file.

The problem is that image is always “null” after image = ByteArrayInputStream(avatar)); … but why ?

I used several contacts and images but every time I get the same problem.

Maybe somebody can tell me what I have to do :).

Sample Code:

public void getAvatar () {

System.out.println (“Fetching avatar”);

BufferedImage image = null;

VCard vCard = new VCard ();

try {

           vCard.load (this.xmppCon, "");

byte[] avatar = vCard.getAvatar();

image = ByteArrayInputStream(avatar));

if (image != null) {

Graphics2D g2 = image.createGraphics();

g2.drawImage(image, 0, 0, null);


ImageIO.write(image, “jpg”, new File(“imageTest.jpg”));

System.out.println (“Should be saved”);

} else

System.out.println (“NARF!”);

} catch (XMPPException e) {


} catch (IOException e) {

System.out.println (“args”);


} catch (Exception e) {

e.printStackTrace ();



push any ideas ? hope