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分析成长之路9
pandas入门 统计分析是数据分析的重要组成部分,它几乎贯穿整个数据分析的流程.运用统计方法,将定量与定性结合,进行的研究活动叫做统计分析.而pandas是统计分析的重要库. 1.pandas数据结 ...
- LeetCode 653. Two Sum IV – Input is a BST
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST s ...
- spring-boot-mustach-template
spring模板引擎mustache https://www.baeldung.com/spring-boot-mustache 这篇文章文件的名字都是.html结尾自己试了下并不行 需要将.html ...
- 【LeetCode】Broken Calculator(坏了的计算器)
这道题是LeetCode里的第991道题. 题目描述: 在显示着数字的坏计算器上,我们可以执行以下两种操作: 双倍(Double):将显示屏上的数字乘 2: 递减(Decrement):将显示屏上的数 ...
- ListView虚拟模式封装
public class ListViewAH : ListViewEx { #region 虚拟模式相关操作 ///<summary> /// 前台行集合 ///</summary ...
- Replication and Triggers
参考官网:https://dev.mysql.com/doc/refman/5.7/en/replication-features-triggers.html 需要了解复制和触发器关系的背景: 程序变 ...
- 【Luogu】P1144最短路计数(BFS)
题目链接 此题使用BFS记录最短路的条数.思路如下:因为是无权无向图,所以只要被BFS到就是最短路径.因此可以记录该点的最短路和最短路的条数:如果点y还没被访问过,则记录dis[y],同时令ans[y ...
- Python GUI 之 Treeview 学习
例子1 from tkinter import *import tkinter.ttk as ttk win = Tk()win.title("Treeview 学习") col ...
- javaweb学习总结(八)——HttpServletResponse对象(二)(转)
(每天都会更新至少一篇以上,有兴趣的可以关注)转载自孤傲苍狼 一.HttpServletResponse常见应用——生成验证码 1.1.生成随机图片用作验证码 生成图片主要用到了一个BufferedI ...
- 森林 BZOJ 3123
题解: 第k大直接用主席树解决 合并利用启发式合并,将较小的连接到较大的树上 #include<cmath> #include<cstdio> #include<cstd ...