gpt4 book ai didi

java - Eclipse BlackBerry 应用程序中未找到源错误

转载 作者:行者123 更新时间:2023-12-02 00:04:57 26 4
gpt4 key购买 nike

我是 BlackBerry 应用程序开发新手。在 httpcon.getResponseCode() 方法中的 HttpConnection 期间,我遇到一个愚蠢的错误,给出了未找到源错误。

请问有人能解决这个错误吗?

这是我的方法:

        net.rim.device.api.io.transport.ConnectionFactory cf = new   net.rim.device.api.io.transport.ConnectionFactory();
httpConn = (HttpConnection) cf.getConnection(url).getConnection();

httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Confirguration/CLDC-1.0");
httpConn.setRequestProperty("Accept_Language", "en-US");
httpConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

httpConn.setRequestProperty("Content-Length",
Integer.toString(postData.length));
os = httpConn.openOutputStream();
os.write(("LoginID=yahoo@sol.com&Password=yah123")
.getBytes("UTF-8"));
os.flush();
os.close();
try {
responseCode = httpConn.getResponseCode();
} catch (IOException ex1) {
//check if it's eof, if yes retrieve code again
if (-1 != ex1.getMessage().indexOf("EOF")) {
try {
responseCode = httpConn.getResponseCode();
} catch (IOException ex2) {
System.out.println(ex2.getMessage());
// handle exception
}
} else {
System.out.println(ex1.getMessage());
// handle exception
}
}
int status = httpConn.getResponseCode();

if (status == HttpConnection.HTTP_OK) {

InputStream input = httpConn.openInputStream();

byte[] bytes = IOUtilities.streamToBytes(input);

StringBuffer raw = new StringBuffer(new String(bytes));
raw.insert(0, "bytes received]\n");
raw.insert(0, bytes.length);
raw.insert(0, '[');

url = raw.toString();

input.close();
} else {
url = "response code = " + status;
}
httpConn.close();
} catch (IOCancelledException e) {
System.out.println(e.toString());
return "";
} catch (IOException e) {

return "";
}

return "";
}

更新:我并不想进入getResponseCode()。 Eclipse 将在此时停止执行,并显示未找到源错误。

最佳答案

@Nate yes we are step into method that time only we are getting Run Time Error.Error is displayed When Getresponsecode() is called

你的 Eclipse 错误看起来像这样吗?

enter image description here

getResponseCode()HttpConnection 类中的一个方法。这是 RIM 的代码,不是您的。您通常不需要单步进入该代码。调试时只需跨过该行即可。您唯一应该希望看到的是该方法的结果,而不是内部发生的情况。

即使您的项目中包含 net_rim_api.jar,也只是为您提供 RIM 类的二进制版本,包括 HttpConnection。它不提供该类的 Java代码。为了进入方法,您还需要有源代码。

关于java - Eclipse BlackBerry 应用程序中未找到源错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14071146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com