Android URL中文处理
不多说,贴上代码。大家都明确
import java.io.File;
import android.net.Uri;
public class Transition {
/**
* @param uri
* @return
* 中文处理
*/
public static String transition(String imageUrl) {
File f = new File(imageUrl);
if(f.exists()){
//正常逻辑代码
}else{
//处理中文路径
/*try {
imageUrl = URLEncoder.encode(imageUrl,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}*/
imageUrl = Uri.encode(imageUrl);
}
imageUrl = imageUrl.replace("%3A", ":");
imageUrl = imageUrl.replace("%2F", "/");
return imageUrl;
}
}
Uri.decode和Uri.encode分析,URLEncoder.encode和URLDecoder.decode分析,URI和URL和URN的差别 请看连接:http://blog.csdn.net/pcaxb/article/details/46859599
Android URL中文处理的更多相关文章
- URL中文转码问题
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- 一种另类的解决URL中文乱码问题--对中文进行加密、解密处理
情景:在资源调度中,首先用户需要选择工作目标,然后跟据选择的工作目标不同而选择不同的账号和代理ip.处理过程如下:点击选择账号,在js中获取工作目标对工作目标进行两次编码(encodeURI(enco ...
- java url中文参数乱码问题
http://www.blogjava.net/jerry-zhaoj/archive/2009/07/16/286993.html 转 JAVA 中URL链接中文参数乱码的处理方法JAVA 中URL ...
- Android Studio中文组(中文社区)
Android Studio中文组(中文社区)http://www.android-studio.org/
- Android API 中文(77)——AdapterView.OnItemSelectedListener
前言 本章内容是android.widget.AdapterView.OnItemSelectedListener,版本为Android 2.3 r1,翻译来自"cnmahj",欢 ...
- Android API 中文(76)——AdapterView.OnItemLongClickListener
前言 本章内容是android.widget.AdapterView.OnItemLongClickListener,版本为Android 2.3 r1,翻译来自"cnmahj", ...
- android api 中文 (75)—— AdapterView.OnItemClickListener
前言 本章内容是android.widget.AdapterView.OnItemClickListener,版本为Android 2.3 r1,翻译来自"麦子",欢迎大家与他交流 ...
- android api 中文 (74)—— AdapterView.AdapterContextMenuInfo
前言 本章内容是android.widget.AdapterView.AdapterContextMenuInfo,版本为Android 2.3 r1,翻译来自"cnmahj",欢 ...
- 解决URL中文乱码问题--对中文进行加密、解密处理
解决URL中文乱码问题--对中文进行加密.解密处理 情景:在资源调度中,首先用户需要选择工作目标,然后跟据选择的工作目标不同而选择不同的账号和代理ip.处理过程如下:点击选择账号,在js中获取工作目标 ...
随机推荐
- Python函数高级
函数对象 在面向对象编程中 一切皆对象 函数在python中是第一类对象 函数可以这么用 可以被引用 def func(): print('hello world !') f=func f() 可 ...
- R语言基础-data.frame
data.frame比较像表格,每一列是一个向量,即每列中的元素是同一类型:所有列具有相同的长度. x = 10:1 y = -4:5 q = c("Ha","oh&qu ...
- django基础(web框架,http协议,django安装)
学习Django之前我们先来看什么是OSI七层模型: 应用层 表示层 应用层(五层模型中把这三层合成一个应用层) http协议 会话层 传输层 提供端口对 ...
- angular controller与directive相互引用
/** * Created by Administrator on 2017/8/28. */ var app =angular.module('app',[]); app.directive('fo ...
- BNUOJ 6727 Bone Collector
Bone Collector Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Origin ...
- POJ 2157 Maze
Maze Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3183 Accepted: 996 Description A ...
- BZOJ 3527 [Zjoi2014]力 ——FFT
[题目分析] FFT,构造数列进行卷积,挺裸的一道题目诶. 还是写起来并不顺手,再练. [代码] #include <cmath> #include <cstdio> #inc ...
- BZOJ 3856: Monster【杂题】
Description Teacher Mai has a kingdom. A monster has invaded this kingdom, and Teacher Mai wants to ...
- (转)WaitForSingleObject函数的使用
WaitForSingleObject 函数 DWORD WaitForSingleObject( HANDLE hObject, DWORD dwMilliseconds ); 第一个参数hObje ...
- linux 中 stat 函数的用途和使用方法
stat 函数讲解 表头文件: #include <sys/stat.h> #include <unistd.h> 定义函数: int stat(const cha ...