A
Angus Parvis
Hi,
I want to write a class that sends a HTTP post request to
http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx and downloads
the file returned as a result.
I know how to send a post request, but fail to read the .DAT-file
returend as the result. Only thing i read is the HTML page I'm posting
the data to.
Here's my code:
--
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.iutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class Dummy {
public static void main(String args[]) throws Exception {
String data = URLEncoder.encode("txtTicker", "UTF-8") + "="
+ URLEncoder.encode("AA", "UTF-8");
data += URLEncoder.encode("cmdSubmit", "UTF-8") + "="
+ URLEncoder.encode("Download", "UTF-8");
// Send data
URL url = new URL(
"http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new
OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
wr.close();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
}
}
--
Any idea how to solve the problem? What do I have to change to read the
..DAT-file returned?
Thanks for your time and help,
Angus
I want to write a class that sends a HTTP post request to
http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx and downloads
the file returned as a result.
I know how to send a post request, but fail to read the .DAT-file
returend as the result. Only thing i read is the HTML page I'm posting
the data to.
Here's my code:
--
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.iutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class Dummy {
public static void main(String args[]) throws Exception {
String data = URLEncoder.encode("txtTicker", "UTF-8") + "="
+ URLEncoder.encode("AA", "UTF-8");
data += URLEncoder.encode("cmdSubmit", "UTF-8") + "="
+ URLEncoder.encode("Download", "UTF-8");
// Send data
URL url = new URL(
"http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new
OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
wr.close();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
}
}
--
Any idea how to solve the problem? What do I have to change to read the
..DAT-file returned?
Thanks for your time and help,
Angus