android之转化inputstream为list


package com.hz2hs.business;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.hz2hs.xmlhandler.BusinessHandler;
import com.hz2hs.xmlhandler.commHandler;

public class BusinessDataManage {


/**
* 通过imputStream获得xml并生成列表
*
* @param is
* @return
*/
public static ArrayList> getListOfInputStream(
InputStream is) {
ArrayList> list = new ArrayList>();

try {
SAXParserFactory factory = SAXParserFactory.newInstance();
XMLReader reader;

reader = factory.newSAXParser().getXMLReader();
// 为XMLReader设置内容处理器
reader.setContentHandler(new BusinessHandler(list));
// 开始解析文件
reader.parse(new InputSource(is));
} catch (Exception e) {
// TODO Auto-generated catch block
// System.out.println(e.toString());
e.printStackTrace();
}
return list;
}


}

你可能感兴趣的:(android之转化inputstream为list)