2
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文件的一些數據並將其寫入一個新文件中。我試圖運行Eclipse的這個計劃,但在控制檯
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;
}
}
你使用的是eclipse的android插件。我不確定它可能使用Java SDK/JRE運行一個android應用程序。在使用插件完成的AVD內運行時,它應該運行良好。 –
看問題。正如@Rajesh所建議的那樣。請閱讀http://developer.android.com/training/basics/firstapp/index.html。 –
Rajesh和mukesh goel 該鏈接不幫助..其他的事情? –