Problem reading image from input Stream

I'm having a problem reading an image through an input stream. It gives me the error

Premature end of JPEG file

sun.awt.image.ImageFormatException: JPEG datastream contains no image

and my code looks like

public Image getImage(String name, String command){

if(command.equals(pCode)){

Image image=null;

System.out.println(name);

InputStream is = getClass().getResourceAsStream(name);

BufferedInputStream bis =new BufferedInputStream(is);

byte[] byBuf =newbyte[10000];

try{

int byteRead = bis.read(byBuf,0,10000);

}catch (IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

image = Toolkit.getDefaultToolkit().createImage(byBuf);

return image;

}

returnnull;

}

And the string name looks when printed is: usr/images/PRLogo.jpg

[1562 byte] By [blackmagea] at [2007-11-27 8:29:10]
# 1
If the image is bigger than 10K, this code will break.You can pass an InputStream to javax.imageio.ImageIO.read. That's probably an easier option than trying to do the buffering yourself.
paulcwa at 2007-7-12 20:19:22 > top of Java-index,Java Essentials,Java Programming...