0
URL url = new URL(binpath);
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
String mt = connection.getContentType();
ResponseBuilder response = Response.ok((Object) is, mt);
response.header("Content-Disposition","attachment; filename=" + binpath.substring(binpath.lastIndexOf('/') + 1, binpath.length()));
return response.build();
我有一個帶有上述代碼的REST服務(Response
)。當被調用的文件保存文件的值如「file1 addsagfdfgfd」REST對字符串的響應文件
當我從另一個類調用此函數並使用Response
獲取如下內容時,它沒有給出響應的內容。它返回
[email protected]
String rp = file1Response.toEntity().toString();
我怎樣才能從REST響應的字符串值(這是一個文件),或者我如何能更改代碼返回一個字符串?
請問您可以發佈整個方法嗎? – Matt