First of all, I'm a newbie to Java and my English is bad, so hope you can understand my problem.
I want to read the text file from this URL: http://www.cophieu68.com/export/metastock.php?id=AAA
Okay, let me explain. This is a Vietnamese stock data website and the link above point to the file aaa.txt which contains the information of the stock with codename is AAA. And I can take the other stocks info by just modifying the value of the id variable.
And my problem is what I get is a bunch of HTML code, not the text file I expect (aaa.txt)
And here is my code:
public static void main(String[] args){
try {
URL url = new URL("http://www.cophieu68.com/export/metastock.php?id=AAA");
URLConnection urlConn = url.openConnection();
System.out.println(urlConn.getContentType()); //it returns text/html
BufferedReader in = new BufferedReader
(new InputStreamReader(urlConn.getInputStream()));
String text;
while ((text = in.readLine()) != null) {
System.out.println(text);
}
in.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Thanks for your help.