File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
src/main/java/com/amadeus/travel Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -88,15 +88,16 @@ public TripDetail post(String body) throws ResponseException {
8888 */
8989 public TripDetail post (File file ) throws ResponseException , IOException {
9090 // Base64 encode file and create request body
91- FileInputStream fileInputStreamReader = new FileInputStream (file );
92- byte [] bytes = new byte [(int )file .length ()];
93- fileInputStreamReader .read (bytes );
94- String encodedFile = Base64 .getEncoder ().encodeToString (bytes );
95- JsonObject body = new JsonObject ();
96- body .addProperty ("payload" , encodedFile );
91+ try ( FileInputStream fileInputStreamReader = new FileInputStream (file )) {
92+ byte [] bytes = new byte [(int )file .length ()];
93+ fileInputStreamReader .read (bytes );
94+ String encodedFile = Base64 .getEncoder ().encodeToString (bytes );
95+ JsonObject body = new JsonObject ();
96+ body .addProperty ("payload" , encodedFile );
9797
98- Response response = client .post ("/v3/travel/trip-parser" , body );
99- return (TripDetail ) Resource .fromObject (response , TripDetail .class );
98+ Response response = client .post ("/v3/travel/trip-parser" , body );
99+ return (TripDetail ) Resource .fromObject (response , TripDetail .class );
100+ }
100101 }
101102
102103 /**
You can’t perform that action at this time.
0 commit comments