例如:public Bitmap returnBitMap() {
String url = "http://www.中文图片.jpg";//诸如此类的中文图片地址
URL myFileUrl = null;
Bitmap bitmap = null;
try {
myFileUrl = new URL(url);
}catch (MalformedURLException e) {
e.printStackTrace();
}try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
is.close();
}catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}提示错误 filenotfindexception
也就是中文路径读取有问题,
给位大侠,有有什么好的解决方法吗?
String url = "http://www.中文图片.jpg";//诸如此类的中文图片地址
URL myFileUrl = null;
Bitmap bitmap = null;
try {
myFileUrl = new URL(url);
}catch (MalformedURLException e) {
e.printStackTrace();
}try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
is.close();
}catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}提示错误 filenotfindexception
也就是中文路径读取有问题,
给位大侠,有有什么好的解决方法吗?
解决方案 »
- android webview 应用启动太慢
- cursor.getColumnIndex(PhoneLookup.NUMBER);没取到值
- android ==号没用????不会把 怎么回事
- 请问android系统如何进行系统备份和还原
- ListView添加项与删除项
- android平台下是否可以这样的一个屏保功能 要用到哪些功能和函数呢
- android控件
- android布局问题
- svg中图形元素的点击事件,求教!!!!!!!
- 怎么设置才能让平板连上电脑后 电脑能浏览平板上所有文件
- android在退出时清楚帐号密码信息
- 求助。。。在csdn上下载了一位朋友的android ocr程序,可是运行起来有点问题不会调试
描述:
URL url = new URL("http://***/中国.doc");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
执行以上代码时,会报java.io.FileNotFoundException异常。
经查,发现是url地址含中文问题导致的。解决办法:
对中文部分进行encode,具体如下:
URL url = new URL("http://***/" + java.net.URLEncoder.encode("中国") + ".doc");