//获取输入流
public static InputStream getInputStream() {
InputStream inputStream = null;
HttpURLConnection httpURLConnection = null;
try {
URL url = new URL("http://10.110.200.157:8080/services/attachment/file/download/AttachmentDownload?id=2429");
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(3000);
httpURLConnection.setDoInput(true);
httpURLConnection.setRequestMethod("GET");
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 200) {
inputStream = httpURLConnection.getInputStream();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return inputStream;
}
//测试:写接口将输入流写入httpResponse