안드로이드 개발 질문/답변 
    (글 수    45,052)
        	
        
        
    package exam.Test;
import java.io.*;
import java.net.*;
import org.htmlcleaner.*;
import android.app.Activity;
import android.content.*;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.*;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Test extends Activity
{
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		URL url = null;
		String sourceUrlString = "http://www.google.com";
        try
        {
        	url = new URL(sourceUrlString);
        	HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        	InputStream is;
        	InputStreamReader isr;
        	BufferedReader br;
        	String content=new String();
        	String buf = null;
        	is = conn.getInputStream();
        	isr = new InputStreamReader(is);
        	br = new BufferedReader(isr);
        	while(true)
        	{
        		buf = br.readLine();
        		System.out.println(buf);
        		if(buf == null)  break;
        		else content += buf+"\n";
        	}
        	HtmlCleaner cleaner=new HtmlCleaner();
        	CleanerProperties props=cleaner.getProperties();
        	TagNode node=null;
        	try
        	{
        		node=cleaner.clean(buf);
        	}
        	catch (IOException e)
        	{
        		e.printStackTrace();
        	}
        	FileOutputStream google;
        	SimpleXmlSerializer se=new SimpleXmlSerializer(props);
        	try
        	{
        		google = openFileOutput("/sdcard/google.xml", Context.MODE_WORLD_READABLE);
        		se.writeXmlToFile(node, "/sdcard/google.xml");
        		google.flush();
        		google.close();
        	}
        	catch (IOException e)
        	{
        		e.printStackTrace();
        	}
        }
        catch (MalformedURLException e)
        {
        	e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}
아무것도 모르는 상태에서 무작정 어플 만드면서 공부하려니 막막하네요ㅠ
한줄 한줄 해석하면서 이 예제 저 예제 보고 있는데
파일로 google.xml로 저장하려는데 sd카드로 넘어가지 않고 에러가 나서 꺼져버리네요
google = openFileOutput("/sdcard/google.xml", Context.MODE_WORLD_READABLE);se.writeXmlToFile(node, "/sdcard/google.xml");
위에 하나만 써도 에러나서 아래꺼는 자바에서는 파일로 저장되서 이걸 추가했는데 그래도 에러나고 아무 반응도 없고...
자바에서는 돌아가는데 안드로이드 프로젝트에서는 안돌아가네요.ㅠ
도와주세요.ㅠ
html를 긁어와서 xml로 저장하려면 어떻게 해야하나요...ㅠ









