Uploaded image for project: 'PUBLIC - Liferay Portal Enterprise Edition'
  1. PUBLIC - Liferay Portal Enterprise Edition
  2. LPE-1645

Added StreamUtil for reading and writing output streams

Details

    Description

      This improvement adds the utility class com.liferay.portal.kernel.util.StreamUtil for reading and writing output streams. This class will automatically do the following:
      1) Ensures streams are closed after reading and writing to them.
      2) Wraps the input stream with the proper BufferedInputStream (if it isn't already)
      3) Wraps the output stream with the proper BufferedOutputStream (if it isn't already)
      4) Use a proper buffer size
      5) Ensures the BufferedInputStream, BufferedOutputStream and the while loop are all using the same buffer size
      To use this class, you can call
      StreamUtil.transfer(inputStream, outputStream)
      or
      StreamUtil.transfer(inputStream, outputStream, 8192)
      where the third parameter is the buffer size. The default buffer size is 8192.

      For portal installation which expect to have intensive I/O operations done, StreamUtil can be configured to use NIO. To enable this, set the following in system(-ext).proerpties:
      com.liferay.portal.kernel.util.StreamUtil.use.nio=true

      API CHANGES:

      Class: com.liferay.util.servlet.ServletResponseUtil

      Method: cleanUp(InputStream inputStream)
      Status: Deprecated
      New method: StreamUtil.cleanUp(inputStream)

      Method: cleanUp(OutputStream outputStream)
      Status: Deprecated
      New method: StreamUtil.cleanUp(outputStream)

      Method: cleanUp(OutputStream outputStream, InputStream inputStream)
      Status: Deprecated
      New method: StreamUtil.cleanUp(inputStream, outputStream)

      Attachments

        Issue Links

          Activity

            People

              michael.saechang Michael Saechang
              brian.chan Brian Chan
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Packages

                  Version Package
                  5.1 EE SP5 (5.1.8)
                  5.2 EE SP3 (5.2.7)