package util_parse;
import android.os.StrictMode;
import android.util.Log;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpParser {
String address;
public HttpParser(String address){
this.address=address;
}
public String JsonParse() {
StrictMode.ThreadPolicy policy =
new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
StringBuilder result = new StringBuilder();
URL url;
try {
url = new URL(address);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if(connection.getResponseCode()==200) {
Log.d("log","connect ok");
String line = "";
BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
while(true) {
line = br.readLine();
if(line == null) break;
result.append(line + "\n");
}
br.close();
}
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
return result.toString();
}
}
[ÀÌ °Ô½Ã¹°Àº ÀÌ°æ¿ë´Ô¿¡ ÀÇÇØ 2016-08-11 21:26:17 ºÎ»ê18±â¿¡¼ º¹»ç µÊ]
[ÀÌ °Ô½Ã¹°Àº ÀÌ°æ¿ë´Ô¿¡ ÀÇÇØ 2016-12-22 20:52:32 ºÎ»ê20±â¿¡¼ º¹»ç µÊ]