public static void printFileContentToResponse(final File file,final OutputStream out) throws IOException {
  FileInputStream in=null;
  if (file.length() == 0) {
    return;
  }
  try {
    in=new FileInputStream(file);
    byte[] buf;
    if (file.length() < MAX_BUFFER_SIZE) {
      buf=new byte[(int)file.length()];
    }
 else {
      buf=new byte[MAX_BUFFER_SIZE];
    }
    int numRead;
    while ((numRead=in.read(buf)) != -1) {
      out.write(buf,0,numRead);
    }
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    try {
      if (in != null) {
        in.close();
      }
    }
 catch (    IOException e) {
      throw e;
    }
  }
}

public static void printFileContentToResponse ( final File file , final OutputStream out ) throws IOException { FileInputStream in = null ; if ( file . length ( ) == 0 ) { return ; } try { in = new FileInputStream ( file ) ; byte [ ] buf ; if ( file . length ( ) < MAX_BUFFER_SIZE ) { buf = new byte [ ( int ) file . length ( ) ] ; } else { buf = new byte [ MAX_BUFFER_SIZE ] ; } int numRead ; while ( ( numRead = in . read ( buf ) ) != - 1 ) { out . write ( buf , 0 , numRead ) ; } } catch ( IOException e ) { throw e ; } finally { try { if ( in != null ) { in . close ( ) ; } } catch ( IOException e ) { throw e ; } } }
print file content to outputstream .
