【新人求助】关于访问网络存储的问题
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import org.apache.http.util.ByteArrayBuffer;
import org.apache.http.util.EncodingUtils;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWeb extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = new TextView(this);
String myString = null;
try {
URL uri = new URL("http://www.baidupcs.com/file/1cb251ec0d568de6a929b520c4aed8d1?xcode=8b8eddcff9b768b0fe3b5383d02719e1682db0a8df3ab0c0&fid=2987144212-250528-3553184730&time=1379061716&sign=FDTAXER-DCb740ccc5511e5e8fedcff06b081203-IajFP7ZTY8WIHqM2f7Ao%2BQKeNbQ%3D&to=wb&fm=N,B,M,mn&expires=8h&rt=sh&r=128013118&logid=2936171168&sh=1&fn=test.txt");
URLConnection ucon = uri.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(100);
int current = 0;
while((current = bis.read()) != -1) {
baf.append((byte)current);
}
myString = new String(baf.toByteArray(), "GBK");
} catch(Exception e) {
myString = e.getMessage();
}
tv.setText(myString);
this.setContentView(tv);
}
}
求大神看一下哪里出问题了?在真机上测试总会抛出异常。
相关推荐
解决WSL2网络和存储问题
链接: https://notes.z-dd.online/2024/02/24/%E8%A7%A3%E5%86%B3WSL2%E7%BD%91%E7%BB%9C%E5%92%8C%E5%AD%98%E5%82%A8%E9%97%AE%E9%A2%98/网络配置问题,主要是不能从外部局域网访问wsl网络,这使得用板子没法挂载wsl里的nfs和使用tftp,网上有些间接的办法解决了这个问题,但很麻烦,懒得去折腾。新的 23H2 系统版本已经直接解决了上面的问题,但我的系统一直未收到相应的正式版的更新推送。
chrome-win64-159.0.8145.0(Canary).zip
内容概要:Chrome for Testing 官方 chrome 159.0.8145.0 win64 平台(金丝雀版通道),原版未修改,附来源说明。 适合人群:Windows 64 位 上的自动化测试工程师、爬虫开发者、CI 环境搭建者。 使用场景及目标:①Chrome for Testing 官方浏览器本体,供自动化测试使用;②与同版本 chromedriver 配套;③CI/容器环境的浏览器运行时。 其他说明:Chrome for Testing 为 Google 官方发布、允许自由分发的文件;本资源为第三方整理的下载便利服务。
chrome-headless-shell-win64-157.0.8103.38(Stable).zip
Chrome for Testing 官方指定版本的 Chrome 浏览器、ChromeDriver 与 Headless Shell 压缩包,适用于 Selenium、Playwright 等自动化测试环境搭建,覆盖 Windows、macOS、Linux 多平台,解压即可使用,无需额外安装或配置。
chrome-win32-159.0.8150.0(Canary).zip
内容概要:Chrome for Testing 官方 chrome 159.0.8150.0 win32 平台(金丝雀版通道),原版未修改,附来源说明。 适合人群:Windows 32 位 上的自动化测试工程师、爬虫开发者、CI 环境搭建者。 使用场景及目标:①Chrome for Testing 官方浏览器本体,供自动化测试使用;②与同版本 chromedriver 配套;③CI/容器环境的浏览器运行时。 其他说明:Chrome for Testing 为 Google 官方发布、允许自由分发的文件;本资源为第三方整理的下载便利服务。
化工MES-石化盈科信息技术有限责任公司.pptx
化工MES-石化盈科信息技术有限责任公司.pptx


