config-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/Stream.java
public static Stream from(File file)
   {
      return new Stream(file) {

         @Override
         public void performHttp(HttpServletRewrite event, EvaluationContext context)
         {
            InputStream stream = null;
            try {
               File file = new File(target.build(event, context, Transpositions.encodePath()));
               stream = new BufferedInputStream(new FileInputStream(file));
               log.debug("Streaming from file [" + file + "] to response.");
               Response.write(stream).perform(event, context);
            }
            catch (Exception e) {
               throw new RewriteException("Error streaming file.", e);
            }
            finally
            {
               if (stream != null)
                  try {
                     stream.close();
                  }
                  catch (IOException e) {
                     throw new RewriteException("Error closing stream.", e);
                  }
            }
         }

         @Override
         public String toString()
         {
            return "Stream.from(\"" + target.getPattern() + "\")";
         }
      };
   }
public static Stream from(File file)
   {
      return new Stream(file) {

         @Override
         public void performHttp(HttpServletRewrite event, EvaluationContext context)
         {
            InputStream stream = null;
            try {
               File file = new File(target.build(event, context, Transpositions.encodePath()));
               stream = new BufferedInputStream(new FileInputStream(file));
               log.debug("Streaming from file [" + file + "] to response.");
               Response.write(stream).perform(event, context);
            }
            catch (Exception e) {
               throw new RewriteException("Error streaming file.", e);
            }
            finally
            {
               if (stream != null)
                  try {
                     stream.close();
                  }
                  catch (IOException e) {
                     throw new RewriteException("Error closing stream.", e);
                  }
            }
         }

         @Override
         public String toString()
         {
            return "Stream.from(\"" + target.getPattern() + "\")";
         }
      };
   }
public static Stream from ( File file ) { return new Stream ( file ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { InputStream stream = null ; try { File file = new File ( target . build ( event , context , Transpositions . encodePath ( ) ) ) ; stream = new BufferedInputStream ( new FileInputStream ( file ) ) ; log . debug ( "Streaming from file [" + file + "] to response." ) ; Response . write ( stream ) . perform ( event , context ) ; } catch ( Exception e ) { throw new RewriteException ( "Error streaming file." , e ) ; } finally { if ( stream != null ) try { stream . close ( ) ; } catch ( IOException e ) { throw new RewriteException ( "Error closing stream." , e ) ; } } } @ Override public String toString ( ) { return "Stream.from(\"" + target . getPattern ( ) + "\")" ; } } ; }
Create an {@link Operation} that streams the given {@link File} to the
{@link HttpServletResponse#getOutputStream()}.

<p>
The given {@link File} path may be parameterized:
<p>
<code>
new File("/tmp/file.txt") <br>
new File("c:\tmp\{param}.txt") <br>
...
</code>
<p>

@param location {@link ParameterizedPattern} specifying the location of the {@link File}.

@see {@link ConfigurationRuleParameterBuilder#where(String)}
Create an { @link Operation } that streams the given { @link File } to the { @link HttpServletResponse#getOutputStream () } .