Class ResponseWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class ResponseWriter
    extends java.io.PrintWriter
    Specialized PrintWriter for servlet Responses

    An instance of ResponseWriter is the PrintWriter subclass returned by Response.getWriter(). It differs from the standard PrintWriter in that:

    • It does not support autoflush
    • The default Locale for format(String, Object...) is the locale obtained by ServletResponse.getLocale()
    • If a write or print method is called while checkError() returns true, then a RuntimeIOException is thrown to stop needless iterations.
    • The writer may be reopen to allow for recycling
    • Field Summary

      • Fields inherited from class java.io.PrintWriter

        out
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      ResponseWriter​(HttpWriter httpWriter, java.util.Locale locale, java.lang.String encoding)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkError()  
      protected void clearError()  
      void close()  
      void complete​(Callback callback)  
      void flush()  
      java.io.PrintWriter format​(java.lang.String format, java.lang.Object... args)  
      java.io.PrintWriter format​(java.util.Locale locale, java.lang.String format, java.lang.Object... args)  
      boolean isFor​(java.util.Locale locale, java.lang.String encoding)  
      void print​(boolean b)  
      void print​(char c)  
      void print​(char[] s)  
      void print​(double d)  
      void print​(float f)  
      void print​(int i)  
      void print​(long l)  
      void print​(java.lang.Object obj)  
      void print​(java.lang.String s)  
      java.io.PrintWriter printf​(java.lang.String format, java.lang.Object... args)  
      java.io.PrintWriter printf​(java.util.Locale l, java.lang.String format, java.lang.Object... args)  
      void println()  
      void println​(boolean b)  
      void println​(char c)  
      void println​(char[] s)  
      void println​(double x)  
      void println​(float x)  
      void println​(int x)  
      void println​(long x)  
      void println​(java.lang.Object x)  
      void println​(java.lang.String s)  
      protected void reopen()  
      protected void setError()  
      void write​(char[] buf)  
      void write​(char[] buf, int off, int len)  
      void write​(int c)  
      void write​(java.lang.String s)  
      void write​(java.lang.String s, int off, int len)  
      • Methods inherited from class java.io.PrintWriter

        append, append, append
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResponseWriter

        public ResponseWriter​(HttpWriter httpWriter,
                              java.util.Locale locale,
                              java.lang.String encoding)
    • Method Detail

      • isFor

        public boolean isFor​(java.util.Locale locale,
                             java.lang.String encoding)
      • reopen

        protected void reopen()
      • clearError

        protected void clearError()
        Overrides:
        clearError in class java.io.PrintWriter
      • checkError

        public boolean checkError()
        Overrides:
        checkError in class java.io.PrintWriter
      • setError

        protected void setError()
        Overrides:
        setError in class java.io.PrintWriter
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.PrintWriter
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.PrintWriter
      • complete

        public void complete​(Callback callback)
      • write

        public void write​(int c)
        Overrides:
        write in class java.io.PrintWriter
      • write

        public void write​(char[] buf,
                          int off,
                          int len)
        Overrides:
        write in class java.io.PrintWriter
      • write

        public void write​(char[] buf)
        Overrides:
        write in class java.io.PrintWriter
      • write

        public void write​(java.lang.String s,
                          int off,
                          int len)
        Overrides:
        write in class java.io.PrintWriter
      • write

        public void write​(java.lang.String s)
        Overrides:
        write in class java.io.PrintWriter
      • print

        public void print​(boolean b)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(char c)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(int i)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(long l)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(float f)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(double d)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(char[] s)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(java.lang.String s)
        Overrides:
        print in class java.io.PrintWriter
      • print

        public void print​(java.lang.Object obj)
        Overrides:
        print in class java.io.PrintWriter
      • println

        public void println()
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(boolean b)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(char c)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(int x)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(long x)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(float x)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(double x)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(char[] s)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(java.lang.String s)
        Overrides:
        println in class java.io.PrintWriter
      • println

        public void println​(java.lang.Object x)
        Overrides:
        println in class java.io.PrintWriter
      • printf

        public java.io.PrintWriter printf​(java.lang.String format,
                                          java.lang.Object... args)
        Overrides:
        printf in class java.io.PrintWriter
      • printf

        public java.io.PrintWriter printf​(java.util.Locale l,
                                          java.lang.String format,
                                          java.lang.Object... args)
        Overrides:
        printf in class java.io.PrintWriter
      • format

        public java.io.PrintWriter format​(java.lang.String format,
                                          java.lang.Object... args)
        Overrides:
        format in class java.io.PrintWriter
      • format

        public java.io.PrintWriter format​(java.util.Locale locale,
                                          java.lang.String format,
                                          java.lang.Object... args)
        Overrides:
        format in class java.io.PrintWriter