我正在尝试创建 HttpURLConnection 类的自定义版本。
现在的课程看起来像这样:
package com.removed;
import java.net.HttpURLConnection;
import java.net.URL;
public abstract class MyHUC extends HttpURLConnection {
public MyHUC(URL url) {
super(url);
// TODO Auto-generated constructor stub
}
}
但是当我打电话时:
MyHUC connection = (MyHUC) url.openConnection();
我收到以下错误:
02-13 14:42:23.639: E/AndroidRuntime(4735): FATAL EXCEPTION: Thread-760
02-13 14:42:23.639: E/AndroidRuntime(4735): java.lang.ClassCastException: libcore.net.http.HttpURLConnectionImpl cannot be cast to com.removed.MyHUC
02-13 14:42:23.639: E/AndroidRuntime(4735): at com.removed.TVSlideActivity.DownloadFile(TVSlideActivity.java:603)
02-13 14:42:23.639: E/AndroidRuntime(4735): at com.removed.TVSlideActivity.access$9(TVSlideActivity.java:588)
02-13 14:42:23.639: E/AndroidRuntime(4735): at com.removed.TVSlideActivity$5.run(TVSlideActivity.java:337)
02-13 14:42:23.639: E/AndroidRuntime(4735): at java.lang.Thread.run(Thread.java:856)
这让我发疯了,我已经在网上寻找了几个小时的解决方案,这里的任何专家可以启发我吗?
谢谢!