日期:2014-05-16 浏览次数:20392 次
function create_dataset_xml_msg() {
var dataset_xml_msg;
dataset_xml_msg = '<dataset>\n';
for(var record_count = 0; record_count <10; record_count++) {
dataset_xml_msg += '<test1 user_name="user_'+record_count+'"/>\n';
}
dataset_xml_msg += '</dataset>\n';
return dataset_xml_msg;
}
create_dataset_xml_msg();
public static InputStream LoadDataSetStr() throws Exception{
Context cx = Context.enter();
cx.setLanguageVersion(Context.VERSION_1_2);
Scriptable scope = cx.initStandardObjects();
File file = new File("dataset.js");
LineNumberReader ln = new LineNumberReader(new FileReader(file));
String js = "";
String s;
while((s = ln.readLine())!=null) {
js += s+"\n";
}
Object result = cx.evaluateString(scope, js,
null, 1, null);
String jsResult = cx.toString(result);
ByteArrayInputStream ba = new ByteArrayInputStream(jsResult.getBytes());
return ba;
}