Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-381

Add FileUtils.copyInputStreamToFile API with option to leave the source open

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.5
    • Utilities
    • None

    Description

      Add the API: copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource)

          /**
           * Copies bytes from an {@link InputStream} <code>source</code> to a file
           * <code>destination</code>. The directories up to <code>destination</code>
           * will be created if they don't already exist. <code>destination</code>
           * will be overwritten if it already exists.
           *
           * @param source  the <code>InputStream</code> to copy bytes from, must not be {@code null}, will be closed
           * @param destination  the non-directory <code>File</code> to write bytes to
           *  (possibly overwriting), must not be {@code null}
           * @param closeSource If true, closes the <code>source</code>
           * @throws IOException if <code>destination</code> is a directory
           * @throws IOException if <code>destination</code> cannot be written
           * @throws IOException if <code>destination</code> needs creating but can't be
           * @throws IOException if an IO error occurs during copying
           * @since 2.5
           */
          public static void copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource) 
                  throws IOException {
      

      Related to IO-380.

      Attachments

        Issue Links

          Activity

            People

              ggregory Gary D. Gregory
              ggregory Gary D. Gregory
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: