【发布时间】:2014-04-18 21:12:24
【问题描述】:
我正在尝试获取在线 pdf 文件的输入流,但程序不工作。 URLConnection 将 url 的 content type 返回为 text/html 而不是 application/pdf。如您所见,https://www.dropbox.com/s/ao3up7xudju4qm0/Amalgabond%20Adhesive%20Agent.pdf url 是 pdf。
我正在为URLConnection 使用以下代码并获取Content Type
URL fileUrl;
try {
String str = "https://www.dropbox.com/s/ao3up7xudju4qm0/Amalgabond%20Adhesive%20Agent.pdf"
fileUrl = new URL(str);
URLConnection connection = fileUrl.openConnection();
Log.i("mustang", "Content-type: " + connection.getContentType());
InputStream is = fileUrl.openStream();
Log.i("mustang", "is.available(): " + is.available());
因此,我无法解析缓冲区。为什么我收到 text/html 内容类型?
谢谢,
【问题讨论】:
标签: httpurlconnection urlconnection