我正在尝试使用以下代码使用简单的 java 类下载文件:
public class Download {
public static void main(String[] args) throws Exception {
Download d = new Download();
d.URLSetUp("http://www.sheldonbrown.com/web_sample1.html");
}
public String URLSetUp(String urlProp) throws Exception {
StringBuffer tempData = new StringBuffer();
String contentXML = "";
String line = "";
URL url1;
try {
url1 = new URL(urlProp);
URLConnection conn = url1.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn
.getOutputStream());
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
while ((line = rd.readLine()) != null) {
tempData.append(line);
}
contentXML = tempData.toString();
wr.close();
rd.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (contentXML != null) {
return contentXML;
} else {
System.out.println("Error");
}
return null;
}
}
它给了我以下错误:
#
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error (434C41535326494C453041525345520E4350500B65), pid=5156, tid=4296
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode)
# An error report file with more information is saved as hs_err_pid5156.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
如果你们有任何灵魂,请告诉我。
谢谢斯内哈
_