Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:129), pid=6223, tid=3064822640
# fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_07-b10
# Java VM: Java HotSpot(TM) Server VM (23.3-b01 mixed mode linux-x86 )
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/kailash/workspace/Parsing/hs_err_pid6223.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
作为 Android 应用程序运行。我是 JAVA 和 android 的新手。并且无法运行此代码,因为控制台中显示了以下错误。所以请任何人都可以帮助我。在这段代码中,我试图从本地 XML 文件中解析一些数据并将其写入一个新文件中。
package com.demo.parsing;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.jsoup.Jsoup;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity{
//private static OutputStreamWriter out;
public static void main(String[] args) throws FileNotFoundException {
FileInputStream pustaka = new FileInputStream("/home/kailash/workspace/parsing/pustaka-feed.xml");
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document feed = builder.parse(pustaka);
NodeList items = feed.getElementsByTagName("item");
List<String> urls = new LinkedList<String>();
for (int i = 0; i < items.getLength(); i++) {
Element item = (Element) items.item(i);
Element description = (Element) item.getElementsByTagName(
"description").item(0);
urls.addAll(getImages(builder, description.getTextContent()));
}
FileWriter f = new FileWriter(new File("outfile"));
for (String url : urls) {
f.write(url + "\n");
}
f.close();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private static List<String> getImages(DocumentBuilder builder, String content) throws SAXException, IOException {
List<String> urls = new LinkedList<String>();
for (org.jsoup.nodes.Element img : Jsoup.parse(content).getElementsByTag("img")) {
urls.add(img.attributes().get("src"));
}
return urls;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}