home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / WriteStream.java < prev    next >
Text File  |  1997-10-25  |  2KB  |  54 lines

  1. /**
  2.  * WriteStream: Using the framework to output binary data.
  3.  */
  4.  
  5. package IISSample;
  6.  
  7. import aspcomp.*;
  8. import com.ms.com.*;
  9.  
  10.  
  11. public class WriteStream 
  12. {
  13.  
  14.     static byte[] byteArray = {
  15.             (byte)'T', (byte)'h', (byte)'i', (byte)'s', (byte)' ', 
  16.             (byte)'b', (byte)'y', (byte)'t', (byte)'e', (byte)' ',
  17.             (byte)'a', (byte)'r', (byte)'r', (byte)'a', (byte)'y',
  18.             (byte)' ', (byte)'i', (byte)'s', (byte)' ', (byte)'b',
  19.             (byte)'e', (byte)'i', (byte)'n', (byte)'g', (byte)' ',
  20.             (byte)'w', (byte)'r', (byte)'i', (byte)'t', (byte)'t',
  21.             (byte)'e', (byte)'n', (byte)' ', (byte)'u', (byte)'s',
  22.             (byte)'i', (byte)'n', (byte)'g', (byte)' ', (byte)'t',
  23.             (byte)'h', (byte)'e', (byte)' ', (byte)'<', (byte)'I',
  24.             (byte)'>', (byte)'r', (byte)'e', (byte)'s', (byte)'p',
  25.             (byte)'o', (byte)'n', (byte)'s', (byte)'e', (byte)'.',
  26.             (byte)'w', (byte)'r', (byte)'i', (byte)'t', (byte)'e',
  27.             (byte)'(', (byte)'b', (byte)'y', (byte)'t', (byte)'e',
  28.             (byte)'[', (byte)']', (byte)')', (byte)'<', (byte)'/',
  29.             (byte)'I', (byte)'>', (byte)' ', (byte)'m', (byte)'e',
  30.             (byte)'t', (byte)'h', (byte)'o', (byte)'d', (byte)' ',
  31.             (byte)'o', (byte)'f', (byte)' ', (byte)' ', (byte)'a',
  32.             (byte)' ', (byte)'s', (byte)'t', (byte)'r', (byte)'e',
  33.             (byte)'a', (byte)'m', (byte)'.', (byte)'<', (byte)'P', 
  34.             (byte)'>'
  35.     };
  36.  
  37.     public void writeBytes() 
  38.     {
  39.         Response response = AspContext.getResponse();
  40.  
  41.         // Use the response object to stream out binary data
  42.         try 
  43.         {
  44.             response.write((byte[])byteArray);
  45.         } 
  46.         catch (Throwable e) 
  47.         {
  48.             response.write("<P>Error writing stream!<P>");
  49.         }
  50.  
  51.     }
  52.  
  53. }
  54.