File tree 1 file changed +9
-8
lines changed
src/main/java/com/amadeus/travel
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 {
88
88
*/
89
89
public TripDetail post (File file ) throws ResponseException , IOException {
90
90
// 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 );
97
97
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
+ }
100
101
}
101
102
102
103
/**
You can’t perform that action at this time.
0 commit comments