얼마전에도 글을 올려서 조언을 구해서 다시 해보았는데... 로그로 아나하나 찍어본 결과 밑에 소스의 빨간 부분에서 더이상 넘어가지 않던데...
인코딩하는 것이 잘 못 된건가여!? 인코딩이 잘못 된거면 어떻게 해결해야 할까여!?ㅠㅠ 인코딩 종류나 방법 좀 알려주세여...ㅠㅠ
================ 소스 ======================
package com.android.PHP_test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.http.client.HttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class PHP_test extends Activity {
/** Called when the activity is first created. */
private String urlname;
private URL url;
private TextView tv;
private String st;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.testview1);
urlname = "http://ipohang.org/Phlife/Storelife/?navi=LIFE";
st = parsing(urlname);
tv.setText(st);
}
private String parsing(String urlname)
{
StringBuilder jsonhtml = new StringBuilder();
try {
url = new URL("urlname); //URL연결 설정
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); //컨넥션 객체 생성
//연결이 되었다면....
if(conn != null)
{
conn.setConnectTimeout(10000);
conn.setUseCaches(false);
//연결이 되어 코드가 리턴되면...
if(conn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
for(;;)
{
//웹상에서 보여지는 텍스트를 라인단위로 읽어 저장
String line = br.readLine();
if(line == null) break;
//tv.setText(line.toString());
Log.d(">>>>>>>>>>>>","====> "+line.toString());
jsonhtml.append(line+"\n");
Log.d(">>>>>>>>","=====> line print");
}
br.close();
String[] bufferArray = jsonhtml.toString().split("\n");
String re = bufferArray[5];
//Log.d(">>>>>>>>>>>>","====> "+re);
}
conn.disconnect();
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return jsonhtml.toString();
}
}