all.
I'm testing my java code for getting weather data from a PHP web page(http://www.agroclimate.org/howard/GDD/getFAWNDailyData.php?loc=490&frommonth=6&fromday=26&fromyear=2009&tomonth=7&today=7&toyear=2009).
My code runs well on my computer (win7, jre6 and jre7). When I access the above link in the web browser (explorer9, chrome), but the browsers download the 'getFAWNDailyData.php' page itself, not running it.
My problem is that the code did not work on other computer with similar specification (win7, jre6 and jre7). The code tried to read the php page source itself, not data generated by the page. And, its web browsers (explorer9, chrome) also download the page itself like mine.
I could not find any difference between two computers, and could not generate the error at other computers.
Could you give any clue which I could check out?
Here is my code;
try {
url = new URL(
"http://www.agroclimate.org/howard/GDD/getFAWNDailyData.php?loc=490&frommonth=6&fromday=26&fromyear=2009&tomonth=7&today=7&toyear=2009");
URLConnection urlConn = url.openConnection();
InputStream is = urlConn.getInputStream();
InputStreamReader reader = new InputStreamReader(is);
BufferedReader bf = new BufferedReader(reader);
int lines = 0;
int wind_count = 0, airtemp_count = 0;
// et starts from the 2nd line
String firstLine = bf.readLine(); // firstLine is "DATETIME,ET"
System.out.print("\n" + "-----" + firstLine + "\n");
String year = "", month = "", day = "", WindCount = "", AirTempCount = "";
int monthNum = 0;
String line = bf.readLine();
System.out.print("\n" + "-----" + line + "\n");
StringTokenizer st = new StringTokenizer(line, ",");
if (st.hasMoreTokens()) {
year = st.nextToken();
}
if (st.hasMoreTokens()) {
month = st.nextToken();
String[] values = month.split(" ");
day = values[0].substring(1);
year = values[2].replace('"', ' ');
year = year.trim();
month = values[1].trim();
monthNum = getMonthValue(month);
}
System.out.println("year---:[" + year + "]");
System.out.println("month---:[" + month + "]");
System.out.println("day---:[" + day + "]");
} catch (MalformedURLException me) {
me.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null)
try {
is.close();
} catch (IOException e) {
;
}
}
Thanks.