File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed
sources/net.sf.j2s.java.core/src/javajs/http Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -287,22 +287,27 @@ public HttpRequest clearFormParts(String name) {
287287 }
288288
289289 private byte [] toBytes (Object data ) {
290- try {
291- if (data == null || data instanceof byte []) {
292- } else if (data instanceof File ) {
293- FileInputStream fis = new FileInputStream ((File ) data );
294- data = getBytes (fis );
295- fis .close ();
296- } else if (data instanceof InputStream ) {
297- InputStream is = (InputStream ) data ;
298- data = getBytes (is );
299- is .close ();
300- } else {
301- data = data .toString ().getBytes ();
290+ if (data == null || data instanceof byte []) {
291+ return (byte []) data ;
292+ } else if (data instanceof File ) {
293+ try (FileInputStream fis = new FileInputStream ((File ) data )) {
294+ return getBytes (fis );
302295 }
303- } catch (IOException e ) {
296+ catch (IOException e ) {
297+ e .printStackTrace ();
298+ return null ;
299+ }
300+ } else if (data instanceof InputStream ) {
301+ try (InputStream is = (InputStream ) data ) {
302+ return getBytes (is );
303+ }
304+ catch (IOException e ) {
305+ e .printStackTrace ();
306+ return null ;
307+ }
308+ } else {
309+ return data .toString ().getBytes ();
304310 }
305- return (byte []) data ;
306311 }
307312
308313 @ Override
You can’t perform that action at this time.
0 commit comments