You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/10/17 16:08:54 UTC
[commons-vfs] 01/02: Sort members.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit 3dbaf7f3933363e97022d3a9c8e85d46140855cc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 17 11:57:18 2019 -0400
Sort members.
---
.../java/org/apache/commons/vfs2/FileContent.java | 46 +++++++++++-----------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileContent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileContent.java
index 170d9b8..054a1a3 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileContent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileContent.java
@@ -81,6 +81,29 @@ public interface FileContent extends Closeable {
Map<String, Object> getAttributes() throws FileSystemException;
/**
+ * Returns the content of a file as a byte array.
+ *
+ * @return The content as a byte array.
+ * @throws IOException if the file content cannot be accessed.
+ * @since 2.4
+ */
+ default byte[] getByteArray() throws IOException {
+ final long sizeL = getSize();
+ if (sizeL > Integer.MAX_VALUE) {
+ throw new IllegalStateException(String.format("File content is too large for a byte array: %,d", sizeL));
+ }
+ final int size = (int) sizeL;
+ final byte[] buf = new byte[size];
+ try (final InputStream in = getInputStream(size)) {
+ int read = 0;
+ for (int pos = 0; pos < size && read >= 0; pos += read) {
+ read = in.read(buf, pos, size - pos);
+ }
+ }
+ return buf;
+ }
+
+ /**
* Retrieves the certificates if any used to sign this file or folder.
*
* @return The certificates, or an empty array if there are no certificates or the file does not support signing.
@@ -117,29 +140,6 @@ public interface FileContent extends Closeable {
InputStream getInputStream() throws FileSystemException;
/**
- * Returns the content of a file as a byte array.
- *
- * @return The content as a byte array.
- * @throws IOException if the file content cannot be accessed.
- * @since 2.4
- */
- default byte[] getByteArray() throws IOException {
- final long sizeL = getSize();
- if (sizeL > Integer.MAX_VALUE) {
- throw new IllegalStateException(String.format("File content is too large for a byte array: %,d", sizeL));
- }
- final int size = (int) sizeL;
- final byte[] buf = new byte[size];
- try (final InputStream in = getInputStream(size)) {
- int read = 0;
- for (int pos = 0; pos < size && read >= 0; pos += read) {
- read = in.read(buf, pos, size - pos);
- }
- }
- return buf;
- }
-
- /**
* Returns an input stream for reading the file's content.
* <p>
* There may only be a single input or output stream open for the file at any time.