Gary Gregory created VFS-713:
--------------------------------

             Summary: Add FileObjectUtils.readProperties(FileObject) method to 
read a .properties file.
                 Key: VFS-713
                 URL: https://issues.apache.org/jira/browse/VFS-713
             Project: Commons VFS
          Issue Type: New Feature
            Reporter: Gary Gregory
            Assignee: Gary Gregory
             Fix For: 2.4


Add:

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

As:
{code:java}
    /**
     * 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;
    }
{code}





--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to