Programmatically downloading Oracle Business Intelligence report using java
I need to download an OBI report as csv using java. When I enter
http://<my_host>:<my_port>/analytics/saw.dll?Go&Action=Download&path=<my_path>&Format=csv
in a browser, download pop-up appears and I can download the file.
However, when i try to download the report using java, it downloads an html content saying "Your browser is not supported by Oracle BI Presentation Services."
Here is piece of code I use:
URL url = new URL("http://<my_host>:<my_port>/analytics/saw.dll?Go&Action=Download&path=<my_path>&Format=csv");
URLConnection urlc = url.openConnection();
urlc.addRequestProperty("User-Agent", "Mozil开发者_如何学JAVAla/4.0");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
bos = new BufferedOutputStream(new FileOutputStream("file.csv"), 1024);
bis = new BufferedInputStream(urlc.getInputStream());
byte[] data = new byte[1024];
while ((x = bis.read(data, 0, 1024)) >= 0) {
bos.write(data, 0, x);
}
So, how can I download the report?
Try using a complete UA string; the javascript that parses UA is sensitive to it.
As you discovered elsewhere, you hit further problems, with a login page with a javascript redirect to the actual page.
精彩评论