File tree 1 file changed +7
-5
lines changed
modules/core-module/src/main/java/org/simplejavamail/internal/util
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -127,12 +127,14 @@ public static String readInputStreamToString(@NotNull final InputStream inputStr
127
127
@ NotNull
128
128
public static byte [] readInputStreamToBytes (@ NotNull final InputStream inputStream )
129
129
throws IOException {
130
- try ( InputStream is = inputStream ) {
131
- byte [] targetArray = new byte [is . available () ];
132
- //noinspection ResultOfMethodCallIgnored
133
- is .read (targetArray );
134
- return targetArray ;
130
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
131
+ byte [] data = new byte [1024 ];
132
+ int read ;
133
+ while (( read = inputStream .read (data , 0 , data . length )) != - 1 ) {
134
+ buffer . write ( data , 0 , read ); ;
135
135
}
136
+ buffer .flush ();
137
+ return buffer .toByteArray ();
136
138
}
137
139
138
140
/**
You can’t perform that action at this time.
0 commit comments