I have a problem in read and display my image file in servlet
Below is my code ... Any help if this code is not correct.
OutputStream out=response.getOutputStream();
FileInputStream fin=null;
BufferedInputStream fBuf=null;
try
{
fin=new FileInputStream("logo.gif");
fBuf=new BufferedInputStream(fin);
final int BufferLen=2048;
byte[] buf=new byte[BufferLen];
int bytesRead;
while(-1!=(bytesRead=fBuf.read(buf,0,buf.length)))
{
out.write(buf,0,bytesRead);
}
if (out!= null) {
out.flush();
out.close();
}
}
catch(FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}
catch(Exception e)
{
;
e.printStackTrace();
}
finally
{
if (fBuf!=null) fBuf.close();
if (fin!=null) fin.close();
}
thanks