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();
私は上記のコード(Response
)でRESTサービスを持っています。呼び出されると "file1 addsagfdfgfd"のようなテキスト値を持つファイルが保存されますRESTレスポンスファイルからストリング
これを別のクラスから呼び出し、Response
を使用してコンテンツを次のように取得すると、応答の内容が表示されません。それは私が(ファイル)応答またはどのように私は、文字列を返すようにコードを変更することができ、残りの文字列値を取得できますか
[email protected]
String rp = file1Response.toEntity().toString();
を返しますか?
方法全体を投稿してください。 – Matt