I try to read web content of xml string where produce from PHP Code. Here the result. But its keep my application crash. It's same when t tried to read www.yahoo.com too.
Here's my code
public static void downloadString(String urlString,String saveLoc, String fileName){
URL url;
try {
url = new URL(urlString);
//URLConnection conn = url.openConnection();
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
int code = conn.getResponseCode();
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
String fullFileName = saveLoc + "//" + fileName;
File file = new File(fullFileName);
if (!file.exists()) file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
while ((inputLine = br.readLine()) != null) {bw.write(inputLine);}
bw.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
I tried to debug and cannot pass from
int code = conn.getResponseCode();
I dont know what exacty the error. Please advice. Thanks.