Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-713

Add FileObjectUtils.readProperties(FileObject) method to read a .properties file.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4
    • None

    Description

      Add:

      • org.apache.commons.vfs2.util.FileObjectUtils.readProperties(FileObject)
      • org.apache.commons.vfs2.util.FileObjectUtils.readProperties(FileObject, Properties)

      As:

          /**
           * Reads the given file into a new {@link Properties}.
           *
           * @param fileObject the file to read
           * @return a new {@link Properties}.
           * @throws IOException
           * @throws FileSystemException On error getting this file's content.
           * @throws IOException On error getting this file's content.
           * @since 2.4
           */
          public static Properties readProperties(final FileObject fileObject) throws FileSystemException, IOException {
              return readProperties(fileObject, new Properties());
          }
      
          /**
           * Reads the given file into a new given {@link Properties}.
           *
           * @param fileObject the file to read
           * @param properties the destination
           * @return a new {@link Properties}.
           * @throws FileSystemException On error getting this file's content.
           * @throws IOException On error getting this file's content.
           * @since 2.4
           */
          public static Properties readProperties(final FileObject fileObject, final Properties properties)
                  throws FileSystemException, IOException {
              if (fileObject == null) {
                  return properties;
              }
              try (InputStream inputStream = fileObject.getContent().getInputStream()) {
                  properties.load(inputStream);
              }
              return properties;
          }
      

      Attachments

        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: